* Get available filter options for building filter UI * Uses event-driven caching; TaskManager's filter indexes make recomputation cheap.
()
| 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. |
no test coverage detected