(startDate: Date, endDate: Date)
| 695 | } |
| 696 | |
| 697 | private async calculateStatsForRange(startDate: Date, endDate: Date): Promise<TimeRangeStats> { |
| 698 | const allTasks = await this.getAllTasks(); |
| 699 | |
| 700 | // Filter tasks that have activity in the range |
| 701 | const tasksInRange = allTasks.filter((task) => { |
| 702 | // Check if task has time entries in the range |
| 703 | if (task.timeEntries && task.timeEntries.length > 0) { |
| 704 | return task.timeEntries.some((entry) => { |
| 705 | if (!entry.startTime) return false; |
| 706 | const entryDate = new Date(entry.startTime); |
| 707 | return entryDate >= startDate && entryDate <= endDate; |
| 708 | }); |
| 709 | } |
| 710 | |
| 711 | // Also include tasks completed in this range |
| 712 | if (task.completedDate) { |
| 713 | const completedDate = new Date(task.completedDate); |
| 714 | return completedDate >= startDate && completedDate <= endDate; |
| 715 | } |
| 716 | |
| 717 | // Include tasks created in this range |
| 718 | if (task.dateCreated) { |
| 719 | const createdDate = new Date(task.dateCreated); |
| 720 | return createdDate >= startDate && createdDate <= endDate; |
| 721 | } |
| 722 | |
| 723 | return false; |
| 724 | }); |
| 725 | |
| 726 | const overall = this.calculateOverallStats(tasksInRange); |
| 727 | const projects = this.calculateProjectStats(tasksInRange); |
| 728 | |
| 729 | return { overall, projects }; |
| 730 | } |
| 731 | |
| 732 | private calculateProjectStats(tasks: TaskInfo[]): ProjectStats[] { |
| 733 | const projectMap = new Map< |
no test coverage detected