MCPcopy
hub / github.com/callumalpass/tasknotes / computeActiveTimeSessions

Function computeActiveTimeSessions

src/utils/timeTrackingUtils.ts:93–134  ·  view source on GitHub ↗
(
	tasks: TaskInfo[],
	getActiveSession: (task: TaskInfo) => TimeEntry | null
)

Source from the content-addressed store, hash-verified

91}
92
93export function computeActiveTimeSessions(
94 tasks: TaskInfo[],
95 getActiveSession: (task: TaskInfo) => TimeEntry | null
96): ActiveSessionsResult {
97 const activeSessions: ActiveSessionInfo[] = [];
98
99 for (const task of tasks) {
100 const activeEntry = getActiveSession(task);
101 if (activeEntry) {
102 const startTime = new Date(activeEntry.startTime);
103 const elapsedMinutes = Math.floor(
104 (Date.now() - startTime.getTime()) / (1000 * 60)
105 );
106
107 activeSessions.push({
108 task: {
109 id: task.path,
110 title: task.title,
111 status: task.status,
112 priority: task.priority,
113 tags: task.tags || [],
114 projects: task.projects || [],
115 },
116 session: {
117 startTime: activeEntry.startTime,
118 description: activeEntry.description,
119 elapsedMinutes,
120 },
121 elapsedMinutes,
122 });
123 }
124 }
125
126 return {
127 activeSessions,
128 totalActiveSessions: activeSessions.length,
129 totalElapsedMinutes: activeSessions.reduce(
130 (sum, session) => sum + session.elapsedMinutes,
131 0
132 ),
133 };
134}
135
136function computeDateRange(options: TimeSummaryOptions): { startDate: Date; endDate: Date } {
137 let startDate: Date;

Callers 4

handlerFunction · 0.90
getActiveTimeSessionsMethod · 0.90

Calls 2

getActiveSessionFunction · 0.85
nowMethod · 0.80

Tested by

no test coverage detected