MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / getGroupTasks

Function getGroupTasks

src/bases/sortOrderUtils.ts:465–543  ·  view source on GitHub ↗
(
	groupKey: string | null,
	groupByProperty: string | null,
	plugin: TaskNotesPlugin,
	options: SortOrderComputationOptions = {}
)

Source from the content-addressed store, hash-verified

463 * Get all tasks matching a group, narrowed by optional extra scope filters.
464 */
465export function getGroupTasks(
466 groupKey: string | null,
467 groupByProperty: string | null,
468 plugin: TaskNotesPlugin,
469 options: SortOrderComputationOptions = {}
470): TaskInfo[] {
471 const sortOrderField = plugin.settings.fieldMapping.sortOrder;
472 const visibleOrder = buildVisibleOrderLookup(options.visibleTaskPaths);
473 const candidateTaskPathSet = options.candidateTaskPaths
474 ? new Set(options.candidateTaskPaths)
475 : null;
476 const allFiles = plugin.app.vault.getMarkdownFiles();
477 const tasks: TaskInfo[] = [];
478
479 for (const file of allFiles) {
480 if (candidateTaskPathSet && !candidateTaskPathSet.has(file.path)) {
481 continue;
482 }
483
484 const frontmatter = plugin.app.metadataCache.getFileCache(file)?.frontmatter;
485 if (!frontmatter) continue;
486
487 if (
488 groupKey !== null &&
489 groupByProperty &&
490 !matchesGroupValue(frontmatter[groupByProperty], groupKey)
491 ) {
492 continue;
493 }
494
495 if (
496 options.scopeFilters?.some(
497 (filter) => !matchesGroupValue(frontmatter[filter.property], filter.value)
498 )
499 ) {
500 continue;
501 }
502
503 const rawSortOrder = frontmatter[sortOrderField];
504 const sortOrder = rawSortOrder !== undefined ? String(rawSortOrder) : undefined;
505 const cached = options.taskInfoCache?.get(file.path);
506 if (cached) {
507 cached.sortOrder = sortOrder;
508 tasks.push(cached);
509 continue;
510 }
511
512 tasks.push({
513 path: file.path,
514 title: file.basename,
515 status: frontmatter["status"] || "open",
516 priority: frontmatter["priority"] || "",
517 archived: frontmatter["archived"] || false,
518 sortOrder,
519 });
520 }
521
522 tasks.sort((a, b) => {

Callers 1

prepareSortOrderUpdateFunction · 0.85

Calls 9

buildVisibleOrderLookupFunction · 0.85
matchesGroupValueFunction · 0.85
tryParseSortRankFunction · 0.85
getMarkdownFilesMethod · 0.80
hasMethod · 0.80
getFileCacheMethod · 0.80
getMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected