MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / computeTaskStats

Method computeTaskStats

src/api/TaskNotesAPI.ts:1795–1832  ·  view source on GitHub ↗
(tasks: TaskInfo[])

Source from the content-addressed store, hash-verified

1793 }
1794
1795 private computeTaskStats(tasks: TaskInfo[]): TaskNotesRuntimeTaskStats {
1796 const statusCounts: Record<string, number> = {};
1797 const priorityCounts: Record<string, number> = {};
1798 let completed = 0;
1799 let active = 0;
1800 let overdue = 0;
1801 let archived = 0;
1802 let withTimeEntries = 0;
1803 let totalTrackedMinutes = 0;
1804 const today = new Date().toISOString().split("T")[0] ?? "";
1805
1806 for (const task of tasks) {
1807 statusCounts[task.status] = (statusCounts[task.status] ?? 0) + 1;
1808 priorityCounts[task.priority] = (priorityCounts[task.priority] ?? 0) + 1;
1809 const isCompleted = this.plugin.statusManager.isCompletedStatus(task.status);
1810 if (isCompleted) completed++;
1811 if (task.archived) archived++;
1812 if (!isCompleted && !task.archived) active++;
1813 if (task.due && task.due < today && !isCompleted && !task.archived) overdue++;
1814 if (task.timeEntries?.length) {
1815 withTimeEntries++;
1816 totalTrackedMinutes += task.totalTrackedTime ?? 0;
1817 }
1818 }
1819
1820 return {
1821 total: tasks.length,
1822 statusCounts,
1823 priorityCounts,
1824 completed,
1825 active,
1826 overdue,
1827 archived,
1828 withTimeEntries,
1829 totalTrackedMinutes,
1830 totalTrackedHours: Math.round((totalTrackedMinutes / 60) * 100) / 100,
1831 };
1832 }
1833
1834 async getTask(path: string): Promise<TaskInfo | null> {
1835 const task = await this.plugin.cacheManager.getTaskInfo(this.normalizeTaskPath(path));

Callers 1

getTaskStatsMethod · 0.95

Calls 1

isCompletedStatusMethod · 0.65

Tested by

no test coverage detected