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

Function resolveTaskForStopTimeTracking

src/cli/helpers/timeTracking.ts:33–56  ·  view source on GitHub ↗
(
	plugin: TaskNotesPlugin,
	resolveExplicitTask: () => Promise<TaskInfo | null>
)

Source from the content-addressed store, hash-verified

31}
32
33export async function resolveTaskForStopTimeTracking(
34 plugin: TaskNotesPlugin,
35 resolveExplicitTask: () => Promise<TaskInfo | null>
36): Promise<TaskInfo> {
37 const explicitTask = await resolveExplicitTask();
38 if (explicitTask) {
39 return explicitTask;
40 }
41
42 const allTasks = await plugin.cacheManager.getAllTasks();
43 const activeTasks = allTasks.filter((task) => !!getLatestActiveEntry(task));
44
45 if (activeTasks.length === 1) {
46 return activeTasks[0];
47 }
48
49 if (activeTasks.length > 1) {
50 throw new Error(
51 "Multiple tasks have active time tracking; pass path, title, or query"
52 );
53 }
54
55 throw new Error("No active time tracking session found");
56}
57
58export function formatTimeTrackingResult(task: TaskInfo): Record<string, unknown> {
59 const activeEntry = pluginGetActiveSession(task);

Callers 1

handlerFunction · 0.90

Calls 2

getLatestActiveEntryFunction · 0.85
getAllTasksMethod · 0.45

Tested by

no test coverage detected