MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / calculateStatsForRange

Method calculateStatsForRange

src/views/StatsView.ts:697–730  ·  view source on GitHub ↗
(startDate: Date, endDate: Date)

Source from the content-addressed store, hash-verified

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<

Callers 3

updateTodayStatsMethod · 0.95
updateWeekStatsMethod · 0.95
updateMonthStatsMethod · 0.95

Calls 3

getAllTasksMethod · 0.95
calculateOverallStatsMethod · 0.95
calculateProjectStatsMethod · 0.95

Tested by

no test coverage detected