Spaces:
Running
Running
compare modalities over rolling 90-day windows
Browse filesFiles changed (4)
153 unmodified lines154155156157158159160161162163164153 unmodified linesGROUP BY ALL ORDER BY month, modality""",)data["modalityTotals"] = rows(con,"""SELECT substr(t, 10) AS name, count(*) AS valueFROM (SELECT unnest(tags) AS t FROM datasets)WHERE t LIKE 'modality:%' GROUP BY 1 ORDER BY 2 DESC""",)153 unmodified lines154155156157158159160161162163164165166167168169170153 unmodified linesGROUP BY ALL ORDER BY month, modality""",)# Rolling 90-day windows ending at the data date, so the comparison is always current.data["modalityTotals"] = rows(con,f"""SELECT substr(t, 10) AS name, count(*) AS value,count(*) FILTER (WHERE createdAt > TIMESTAMP '{now}' - INTERVAL 90 DAY) AS last90,count(*) FILTER (WHERE createdAt > TIMESTAMP '{now}' - INTERVAL 180 DAYAND createdAt <= TIMESTAMP '{now}' - INTERVAL 90 DAY) AS prev90,count(*) FILTER (WHERE createdAt > TIMESTAMP '{now}' - INTERVAL 455 DAYAND createdAt <= TIMESTAMP '{now}' - INTERVAL 365 DAY) AS ago90FROM (SELECT createdAt, unnest(tags) AS t FROM datasets)WHERE t LIKE 'modality:%' GROUP BY 1 ORDER BY 2 DESC""",)
702 unmodified lines70370470570670770870971071171271371471523 unmodified lines7397407417427437447457467477487497507517527537547556 unmodified lines7627637647657667677687697704 unmodified lines775776777778779780781702 unmodified lines};const modColor = (name) => MODALITY_COLORS[name] || "var(--other)";const modality = pivot(D.modalityMonthly, "month", "modality", D.modalityTotals.map((d) => d.name));const modalityGrowth = (name) => {const v = modality.values[name], n = v.length;const last3 = v.slice(n - 3).reduce((a, b) => a + b, 0), ago3 = v.slice(n - 15, n - 12).reduce((a, b) => a + b, 0);return ago3 ? last3 / ago3 : 0;};// Start with the three fastest growers, since the big modalities would flatten them on a shared scale.const modalityPicked = new Set(D.modalityTotals.map((d) => d.name).sort((a, b) => modalityGrowth(b) - modalityGrowth(a)).slice(0, 3));function renderModalityChips() {const box = document.getElementById("modality-chips");23 unmodified lines// Ranked by growth vs a year ago, so small fast-growing modalities aren't buried under text and tabular.function renderModality() {const mod = modality;const n = mod.xs.length;const sum = (v, a, b) => v.slice(a, b).reduce((x, y) => x + y, 0);const rows = D.modalityTotals.map((d) => {const v = mod.values[d.name];return { name: d.name, total: d.value, v, last3: sum(v, n - 3, n), prev3: sum(v, n - 6, n - 3), ago3: sum(v, n - 15, n - 12) };}).filter((r) => r.last3 > 0).sort((a, b) => (b.ago3 ? b.last3 / b.ago3 : Infinity) - (a.ago3 ? a.last3 / a.ago3 : Infinity));document.getElementById("modality-sub").textContent =`New datasets tagged with each modality in ${monTick(mod.xs[n - 3])} – ${monTick(mod.xs[n - 1])}, ranked by growth vs the same 3 months a year earlier`;const tb = table(document.getElementById("modality"), [{ t: "Modality" }, { t: "Last 3 mo", cls: "n" }, { t: "vs prior 3 mo", cls: "n" }, { t: "vs year ago", cls: "n" },{ t: "All time", cls: "n opt" }, { t: "Per month, last 24 months · own scale", cls: "opt" },]);const trends = [];6 unmodified linesel("td", { class: "n opt dim", text: fmtC.format(r.total) }, tr);trends.push([el("td", { class: "trend opt" }, tr), r]);hoverRow(tr, r.name, [{ label: `${monTick(mod.xs[n - 3])} – ${monTick(mod.xs[n - 1])}`, value: fmtInt.format(r.last3), color: modColor(r.name) },{ label: `${monTick(mod.xs[n - 6])} – ${monTick(mod.xs[n - 4])}`, value: fmtInt.format(r.prev3) },{ label: `${monTick(mod.xs[n - 15])} – ${monTick(mod.xs[n - 13])}`, value: fmtInt.format(r.ago3) },{ label: "All time", value: fmtInt.format(r.total) },]);}4 unmodified lines}const best = rows.find((r) => r.ago3);document.getElementById("modality-foot").textContent =`Fastest growing: ${best.name}, ${fmtInt.format(best.last3)} new datasets in the last 3 months vs ${fmtInt.format(best.ago3)} a year earlier. Untagged datasets aren't counted.`;}// ---------- activity table ----------702 unmodified lines70370470570670770870971071171271371471571671771823 unmodified lines7427437447457467477487497507517527537547557566 unmodified lines7637647657667677687697707714 unmodified lines776777778779780781782702 unmodified lines};const modColor = (name) => MODALITY_COLORS[name] || "var(--other)";const modality = pivot(D.modalityMonthly, "month", "modality", D.modalityTotals.map((d) => d.name));// Last 90 days vs the same 90 days a year earlier; 0 when there's nothing to compare against.const modalityGrowth = (d) => (d.ago90 ? d.last90 / d.ago90 : 0);// Start with the three fastest growers, since the big modalities would flatten them on a shared scale.const modalityPicked = new Set([...D.modalityTotals].sort((a, b) => modalityGrowth(b) - modalityGrowth(a)).slice(0, 3).map((d) => d.name));// "Aug 1 – Oct 29" for the 90 days ending `endDaysAgo` days before the data date.function windowLabel(endDaysAgo) {const day = 864e5, end = upd.getTime() - endDaysAgo * day;const f = (t) => new Date(t).toLocaleDateString("en-US", { month: "short", day: "numeric", year: endDaysAgo ? "numeric" : undefined, timeZone: "UTC" });return `${f(end - 89 * day)} – ${f(end)}`;}function renderModalityChips() {const box = document.getElementById("modality-chips");23 unmodified lines// Ranked by growth vs a year ago, so small fast-growing modalities aren't buried under text and tabular.function renderModality() {const mod = modality;const rows = D.modalityTotals.map((d) => {const v = mod.values[d.name];return { name: d.name, total: d.value, v, last3: d.last90, prev3: d.prev90, ago3: d.ago90 };}).filter((r) => r.last3 > 0).sort((a, b) => (b.ago3 ? b.last3 / b.ago3 : Infinity) - (a.ago3 ? a.last3 / a.ago3 : Infinity));document.getElementById("modality-sub").textContent =`New datasets tagged with each modality in the last 90 days (${windowLabel(0)}), ranked by growth vs the same 90 days a year earlier`;const tb = table(document.getElementById("modality"), [{ t: "Modality" }, { t: "Last 90 days", cls: "n" }, { t: "vs prior 90", cls: "n" }, { t: "vs year ago", cls: "n" },{ t: "All time", cls: "n opt" }, { t: "Per month, last 24 months · own scale", cls: "opt" },]);const trends = [];6 unmodified linesel("td", { class: "n opt dim", text: fmtC.format(r.total) }, tr);trends.push([el("td", { class: "trend opt" }, tr), r]);hoverRow(tr, r.name, [{ label: windowLabel(0), value: fmtInt.format(r.last3), color: modColor(r.name) },{ label: windowLabel(90), value: fmtInt.format(r.prev3) },{ label: windowLabel(365), value: fmtInt.format(r.ago3) },{ label: "All time", value: fmtInt.format(r.total) },]);}4 unmodified lines}const best = rows.find((r) => r.ago3);document.getElementById("modality-foot").textContent =`Fastest growing: ${best.name}, ${fmtInt.format(best.last3)} new datasets in the last 90 days vs ${fmtInt.format(best.ago3)} a year earlier. Untagged datasets aren't counted.`;}// ---------- activity table ----------
build/build.py+9-3
index.html
site/template.html+16-15
stats.json