feat(graph): Implement Graph View with Dagre Layout and Epic Scope (bb-18e)
This commit is contained in:
parent
7ab23448f0
commit
8490cb1d8c
33 changed files with 4936 additions and 38 deletions
69
src/lib/aggregate-read.ts
Normal file
69
src/lib/aggregate-read.ts
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import type { BeadDependency, BeadIssueWithProject } from './types';
|
||||
import type { ProjectScopeOption } from './project-scope';
|
||||
import { readIssuesFromDisk } from './read-issues';
|
||||
|
||||
function scopeIssueId(projectKey: string, issueId: string): string {
|
||||
return `${projectKey}::${issueId}`;
|
||||
}
|
||||
|
||||
function remapDependencies(
|
||||
dependencies: BeadDependency[],
|
||||
scopedIssueByOriginalId: Map<string, string>,
|
||||
): BeadDependency[] {
|
||||
return dependencies.map((dependency) => ({
|
||||
...dependency,
|
||||
target: scopedIssueByOriginalId.get(dependency.target) ?? dependency.target,
|
||||
}));
|
||||
}
|
||||
|
||||
function scopeIssuesForProject(
|
||||
project: ProjectScopeOption,
|
||||
issues: BeadIssueWithProject[],
|
||||
): BeadIssueWithProject[] {
|
||||
const scopedIssueByOriginalId = new Map<string, string>();
|
||||
for (const issue of issues) {
|
||||
scopedIssueByOriginalId.set(issue.id, scopeIssueId(project.key, issue.id));
|
||||
}
|
||||
|
||||
return issues.map((issue) => {
|
||||
const scopedId = scopedIssueByOriginalId.get(issue.id) ?? scopeIssueId(project.key, issue.id);
|
||||
return {
|
||||
...issue,
|
||||
id: scopedId,
|
||||
dependencies: remapDependencies(issue.dependencies, scopedIssueByOriginalId),
|
||||
metadata: {
|
||||
...issue.metadata,
|
||||
original_id: issue.id,
|
||||
project_key: project.key,
|
||||
},
|
||||
project: {
|
||||
...issue.project,
|
||||
key: project.key,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export async function readIssuesForScope(options: {
|
||||
mode: 'single' | 'aggregate';
|
||||
selected: ProjectScopeOption;
|
||||
scopeOptions: ProjectScopeOption[];
|
||||
}): Promise<BeadIssueWithProject[]> {
|
||||
if (options.mode === 'single') {
|
||||
return readIssuesFromDisk({
|
||||
projectRoot: options.selected.root,
|
||||
projectSource: options.selected.source,
|
||||
});
|
||||
}
|
||||
|
||||
const result = await Promise.all(
|
||||
options.scopeOptions.map(async (project) => {
|
||||
const issues = await readIssuesFromDisk({
|
||||
projectRoot: project.root,
|
||||
projectSource: project.source,
|
||||
});
|
||||
return scopeIssuesForProject(project, issues);
|
||||
}),
|
||||
);
|
||||
return result.flat();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue