Skip to content

Commit a37cf8e

Browse files
committed
feat(site): plot CPU engineering samples across the growth timeline
Reads the satellite repo's history.json and adds its record count as of each point's date, so it grows along the chart instead of appearing as one step at the newest point. Without history.json the chart is as before. Refs #19
1 parent 8dfce52 commit a37cf8e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

site/src/scripts/techapi.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,20 @@ function countUp(node, target, opts = {}) {
444444
if (!points || !points.length) points = await pointsFromGitHubApi();
445445
if (!points.length) throw new Error("empty history");
446446

447+
// Add each satellite's count as of every point's date (its own history.json).
448+
const es = await fetch("https://gettechapi.github.io/cpu-engineering-samples/history.json")
449+
.then((r) => (r.ok ? r.json() : Promise.reject()))
450+
.then((d) => (d.points || []).map((p) => ({ t: new Date(p.date).getTime(), count: p.count })))
451+
.catch(() => []);
452+
if (es.length) {
453+
for (const point of points) {
454+
const asOf = es.filter((p) => p.t <= point.dateValue).pop();
455+
if (!asOf) continue;
456+
point.rows = [...point.rows, { key: "cpu_es", count: asOf.count }];
457+
point.total += asOf.count;
458+
}
459+
}
460+
447461
const currentTotal = totalRecords(currentManifest);
448462
const latest = points[points.length - 1];
449463
if (latest.total !== currentTotal) {

0 commit comments

Comments
 (0)