mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 06:42:03 +00:00
perf(ui): smooth large lists and graphs
This commit is contained in:
@@ -7,6 +7,8 @@ export {
|
||||
resolveDependencies,
|
||||
areDependenciesSatisfied,
|
||||
getBlockingDependencies,
|
||||
createFeatureMap,
|
||||
getBlockingDependenciesFromMap,
|
||||
wouldCreateCircularDependency,
|
||||
dependencyExists,
|
||||
getAncestors,
|
||||
|
||||
@@ -229,6 +229,49 @@ export function getBlockingDependencies(feature: Feature, allFeatures: Feature[]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a lookup map for features by id.
|
||||
*
|
||||
* @param features - Features to index
|
||||
* @returns Map keyed by feature id
|
||||
*/
|
||||
export function createFeatureMap(features: Feature[]): Map<string, Feature> {
|
||||
const featureMap = new Map<string, Feature>();
|
||||
for (const feature of features) {
|
||||
if (feature?.id) {
|
||||
featureMap.set(feature.id, feature);
|
||||
}
|
||||
}
|
||||
return featureMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the blocking dependencies using a precomputed feature map.
|
||||
*
|
||||
* @param feature - Feature to check
|
||||
* @param featureMap - Map of all features by id
|
||||
* @returns Array of feature IDs that are blocking this feature
|
||||
*/
|
||||
export function getBlockingDependenciesFromMap(
|
||||
feature: Feature,
|
||||
featureMap: Map<string, Feature>
|
||||
): string[] {
|
||||
const dependencies = feature.dependencies;
|
||||
if (!dependencies || dependencies.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const blockingDependencies: string[] = [];
|
||||
for (const depId of dependencies) {
|
||||
const dep = featureMap.get(depId);
|
||||
if (dep && dep.status !== 'completed' && dep.status !== 'verified') {
|
||||
blockingDependencies.push(depId);
|
||||
}
|
||||
}
|
||||
|
||||
return blockingDependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if adding a dependency from sourceId to targetId would create a circular dependency.
|
||||
* When we say "targetId depends on sourceId", we add sourceId to targetId.dependencies.
|
||||
|
||||
Reference in New Issue
Block a user