MCPcopy Create free account
hub / github.com/codag-megalith/codag-visualizer / findPrimaryFile

Method findPrimaryFile

frontend/src/cache.ts:688–710  ·  view source on GitHub ↗

* Find primary file for a workflow (file with most nodes)

(
        nodeIds: string[],
        nodeToFile: Map<string, string>
    )

Source from the content-addressed store, hash-verified

686 * Find primary file for a workflow (file with most nodes)
687 */
688 private findPrimaryFile(
689 nodeIds: string[],
690 nodeToFile: Map<string, string>
691 ): string {
692 const fileCounts = new Map<string, number>();
693
694 for (const id of nodeIds) {
695 const file = nodeToFile.get(id);
696 if (file) {
697 fileCounts.set(file, (fileCounts.get(file) || 0) + 1);
698 }
699 }
700
701 let maxFile = 'unknown';
702 let maxCount = 0;
703 for (const [file, count] of fileCounts) {
704 if (count > maxCount) {
705 maxCount = count;
706 maxFile = file;
707 }
708 }
709 return maxFile;
710 }
711
712 /**
713 * Merge new cross-file edges with replace-on-conflict behavior

Callers 1

setAnalysisResultMethod · 0.95

Calls 2

setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected