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

Method getFilterOptions

src/services/FilterService.ts:479–511  ·  view source on GitHub ↗

* Get available filter options for building filter UI * Uses event-driven caching; TaskManager's filter indexes make recomputation cheap.

()

Source from the content-addressed store, hash-verified

477 * Uses event-driven caching; TaskManager's filter indexes make recomputation cheap.
478 */
479 async getFilterOptions(): Promise<FilterOptions> {
480 const now = Date.now();
481
482 // Return cached options if valid and not expired by fallback TTL
483 if (
484 this.filterOptionsCache &&
485 now - this.filterOptionsCacheTimestamp < this.filterOptionsCacheTTL
486 ) {
487 this.filterOptionsCacheHits++;
488 return this.filterOptionsCache;
489 }
490
491 // Cache miss - compute fresh options
492
493 const freshOptions = buildFilterOptions({
494 statuses: this.statusManager.getAllStatuses(),
495 priorities: this.priorityManager.getAllPriorities(),
496 contexts: this.cacheManager.getAllContexts(),
497 projects: this.cacheManager.getAllProjects(),
498 tags: this.cacheManager.getAllTags(),
499 taskPaths: this.cacheManager.getAllTaskPaths(),
500 rootFolderLabel: this.translate("services.filter.folders.root", "(Root)"),
501 userFields: this.runtime?.settings?.userFields || [],
502 });
503
504 this.filterOptionsComputeCount++;
505
506 // Update cache and timestamp
507 this.filterOptionsCache = freshOptions;
508 this.filterOptionsCacheTimestamp = now;
509
510 return freshOptions;
511 }
512
513 /**
514 * Invalidate cached filter options after an indexed field changes.

Callers 1

registerFilterToolsMethod · 0.45

Calls 9

translateMethod · 0.95
buildFilterOptionsFunction · 0.90
nowMethod · 0.80
getAllContextsMethod · 0.80
getAllProjectsMethod · 0.80
getAllTagsMethod · 0.80
getAllTaskPathsMethod · 0.65
getAllStatusesMethod · 0.45
getAllPrioritiesMethod · 0.45

Tested by

no test coverage detected