Visitar URL original
perf(dataflow): avoid repeated flow index scans by cookingwithvlad-del · Pull Request #1109 · tt-a1i/archify · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions archify/renderers/dataflow/dataflow-compiler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,7 @@ export function compileDataflow({ dataflow, sourceEvidence, qualityProfile: requ

const flowList = asArray(dataflow.flows);
const stageById = new Map(asArray(dataflow.nodes).map((node) => [node.id, node.stage]));
for (const flow of flowList) {
const flowIndex = flowList.indexOf(flow);
for (const [flowIndex, flow] of flowList.entries()) {
for (const [field, endpoint] of [['from', 'source'], ['to', 'target']]) {
if (nodes.has(flow[field])) continue;
const problem = `Flow "${flow.label || flow[field]}" references unknown ${endpoint} "${flow[field]}".`;
Expand Down
12 changes: 12 additions & 0 deletions test/dataflow-automatic-layout.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ function pipeline() {
};
}

test('unknown-flow diagnostics retain their collection index', t => {
const diagram = pipeline();
diagram.flows[2].to = 'ghost';
const { result, receipt } = inspect(t, diagram);
assert.notEqual(result.status, 0);
const diagnostic = receipt.diagnostics.find(({ code }) => code === 'dataflow/unknown-endpoint');
assert.ok(diagnostic);
assert.equal(diagnostic.subject.path, '/flows/2/to');
assert.ok(diagnostic.supportedFixes.length > 0);
assert.ok(diagnostic.supportedFixes.every(fix => fix.startsWith('set /flows/2/to to ')));
});

test('automatic dataflow width contains a nearby authored label without moving its pin', t => {
const diagram = {
schema_version: 1, diagram_type: 'dataflow',
Expand Down
Loading