Skip to content
Merged
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
24 changes: 1 addition & 23 deletions pm-stack/aggregator/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5048,29 +5048,7 @@ import { applyInequalityFilters, bandIndex, computeRecommendations, logEdges, no
// price within 25% of the band leader; the scale select multiplies all
// three. Lane charts visualize the same near-leader choices as the
// comparison tables; they do not recalculate band membership.
function logEdges(vals, n) {
var xs = vals.filter(function (v) { return v != null && v > 0; });
if (!xs.length) return [];
var mn = Math.min.apply(null, xs), mx = Math.max.apply(null, xs);
if (mn === mx) return [mn, mx];
var edges = [];
for (var i = 0; i <= n; i++) edges.push(mn * Math.pow(mx / mn, i / n));
return edges;
}
function scoreEdges(rows, n) {
var xs = rows.map(function (p) { return p.score; }).filter(function (v) { return v != null; });
if (!xs.length) return [];
var mn = Math.min.apply(null, xs), mx = Math.max.apply(null, xs);
var edges = [];
for (var i = 0; i <= n; i++) edges.push(mn + ((mx - mn) * i) / n);
return edges;
}
function bandIndex(v, edges) {
for (var i = 0; i < edges.length - 1; i++) {
if (v >= edges[i] && (i === edges.length - 2 ? v <= edges[i + 1] : v < edges[i + 1])) return i;
}
return -1;
}
// logEdges/scoreEdges/bandIndex come from the aa-explorer-computations.js import above (#7562): no inline copies here - an inline definition would shadow the tested module implementation.
function chipFor(p, leader) {
var notes = [];
if (leader && leader.key !== p.key) {
Expand Down
19 changes: 19 additions & 0 deletions pm-stack/aggregator/test/aa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,25 @@ describe("aa routes (HTTP, fixtures)", () => {
expect(asset).toContain("export function computeRecommendations");
expect(asset).toContain("export function projectTask");
});

test("/aa page script does not redefine the computations it imports (#7562)", async () => {
// Oracle: the emitted page must execute the tested module copies.
// Any inline "function <name>(" for an imported name shadows the
// module implementation inside the page script (#3737 regression).
const page = await (await fetch("http://127.0.0.1:" + port + "/aa")).text();
const importMatch = page.match(/import \{([^}]+)\} from "\/assets\/aa-explorer-computations\.js";/);
expect(importMatch).not.toBeNull();
const imported = (importMatch as RegExpMatchArray)[1]
.split(",")
.map((part) => part.trim())
.filter(Boolean);
expect(imported).toContain("logEdges");
expect(imported).toContain("scoreEdges");
expect(imported).toContain("bandIndex");
for (const name of imported) {
expect(page).not.toMatch(new RegExp("function " + name + "\\s*\\("));
}
});
});

describe("aa chart expand + zoom/pan (#3298)", () => {
Expand Down
Loading