Spaces:
Running
Running
compare modalities over rolling 90-day windows
Browse files- build/build.py +9 -3
- index.html +0 -0
- site/template.html +16 -15
- stats.json +0 -0
build/build.py
CHANGED
|
@@ -154,11 +154,17 @@ def compute(con: duckdb.DuckDBPyConnection) -> dict:
|
|
| 154 |
GROUP BY ALL ORDER BY month, modality
|
| 155 |
""",
|
| 156 |
)
|
|
|
|
| 157 |
data["modalityTotals"] = rows(
|
| 158 |
con,
|
| 159 |
-
"""
|
| 160 |
-
SELECT substr(t, 10) AS name, count(*) AS value
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
WHERE t LIKE 'modality:%' GROUP BY 1 ORDER BY 2 DESC
|
| 163 |
""",
|
| 164 |
)
|
|
|
|
| 154 |
GROUP BY ALL ORDER BY month, modality
|
| 155 |
""",
|
| 156 |
)
|
| 157 |
+
# Rolling 90-day windows ending at the data date, so the comparison is always current.
|
| 158 |
data["modalityTotals"] = rows(
|
| 159 |
con,
|
| 160 |
+
f"""
|
| 161 |
+
SELECT substr(t, 10) AS name, count(*) AS value,
|
| 162 |
+
count(*) FILTER (WHERE createdAt > TIMESTAMP '{now}' - INTERVAL 90 DAY) AS last90,
|
| 163 |
+
count(*) FILTER (WHERE createdAt > TIMESTAMP '{now}' - INTERVAL 180 DAY
|
| 164 |
+
AND createdAt <= TIMESTAMP '{now}' - INTERVAL 90 DAY) AS prev90,
|
| 165 |
+
count(*) FILTER (WHERE createdAt > TIMESTAMP '{now}' - INTERVAL 455 DAY
|
| 166 |
+
AND createdAt <= TIMESTAMP '{now}' - INTERVAL 365 DAY) AS ago90
|
| 167 |
+
FROM (SELECT createdAt, unnest(tags) AS t FROM datasets)
|
| 168 |
WHERE t LIKE 'modality:%' GROUP BY 1 ORDER BY 2 DESC
|
| 169 |
""",
|
| 170 |
)
|
index.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
site/template.html
CHANGED
|
@@ -703,13 +703,16 @@ const MODALITY_COLORS = {
|
|
| 703 |
};
|
| 704 |
const modColor = (name) => MODALITY_COLORS[name] || "var(--other)";
|
| 705 |
const modality = pivot(D.modalityMonthly, "month", "modality", D.modalityTotals.map((d) => d.name));
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
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);
|
| 709 |
-
return ago3 ? last3 / ago3 : 0;
|
| 710 |
-
};
|
| 711 |
// Start with the three fastest growers, since the big modalities would flatten them on a shared scale.
|
| 712 |
-
const modalityPicked = new Set(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 713 |
|
| 714 |
function renderModalityChips() {
|
| 715 |
const box = document.getElementById("modality-chips");
|
|
@@ -739,17 +742,15 @@ function renderModalityChart() {
|
|
| 739 |
// Ranked by growth vs a year ago, so small fast-growing modalities aren't buried under text and tabular.
|
| 740 |
function renderModality() {
|
| 741 |
const mod = modality;
|
| 742 |
-
const n = mod.xs.length;
|
| 743 |
-
const sum = (v, a, b) => v.slice(a, b).reduce((x, y) => x + y, 0);
|
| 744 |
const rows = D.modalityTotals.map((d) => {
|
| 745 |
const v = mod.values[d.name];
|
| 746 |
-
return { name: d.name, total: d.value, v, last3:
|
| 747 |
}).filter((r) => r.last3 > 0).sort((a, b) => (b.ago3 ? b.last3 / b.ago3 : Infinity) - (a.ago3 ? a.last3 / a.ago3 : Infinity));
|
| 748 |
|
| 749 |
document.getElementById("modality-sub").textContent =
|
| 750 |
-
`New datasets tagged with each modality in
|
| 751 |
const tb = table(document.getElementById("modality"), [
|
| 752 |
-
{ t: "Modality" }, { t: "Last
|
| 753 |
{ t: "All time", cls: "n opt" }, { t: "Per month, last 24 months · own scale", cls: "opt" },
|
| 754 |
]);
|
| 755 |
const trends = [];
|
|
@@ -762,9 +763,9 @@ function renderModality() {
|
|
| 762 |
el("td", { class: "n opt dim", text: fmtC.format(r.total) }, tr);
|
| 763 |
trends.push([el("td", { class: "trend opt" }, tr), r]);
|
| 764 |
hoverRow(tr, r.name, [
|
| 765 |
-
{ label:
|
| 766 |
-
{ label:
|
| 767 |
-
{ label:
|
| 768 |
{ label: "All time", value: fmtInt.format(r.total) },
|
| 769 |
]);
|
| 770 |
}
|
|
@@ -775,7 +776,7 @@ function renderModality() {
|
|
| 775 |
}
|
| 776 |
const best = rows.find((r) => r.ago3);
|
| 777 |
document.getElementById("modality-foot").textContent =
|
| 778 |
-
`Fastest growing: ${best.name}, ${fmtInt.format(best.last3)} new datasets in the last
|
| 779 |
}
|
| 780 |
|
| 781 |
// ---------- activity table ----------
|
|
|
|
| 703 |
};
|
| 704 |
const modColor = (name) => MODALITY_COLORS[name] || "var(--other)";
|
| 705 |
const modality = pivot(D.modalityMonthly, "month", "modality", D.modalityTotals.map((d) => d.name));
|
| 706 |
+
// Last 90 days vs the same 90 days a year earlier; 0 when there's nothing to compare against.
|
| 707 |
+
const modalityGrowth = (d) => (d.ago90 ? d.last90 / d.ago90 : 0);
|
|
|
|
|
|
|
|
|
|
| 708 |
// Start with the three fastest growers, since the big modalities would flatten them on a shared scale.
|
| 709 |
+
const modalityPicked = new Set([...D.modalityTotals].sort((a, b) => modalityGrowth(b) - modalityGrowth(a)).slice(0, 3).map((d) => d.name));
|
| 710 |
+
// "Aug 1 – Oct 29" for the 90 days ending `endDaysAgo` days before the data date.
|
| 711 |
+
function windowLabel(endDaysAgo) {
|
| 712 |
+
const day = 864e5, end = upd.getTime() - endDaysAgo * day;
|
| 713 |
+
const f = (t) => new Date(t).toLocaleDateString("en-US", { month: "short", day: "numeric", year: endDaysAgo ? "numeric" : undefined, timeZone: "UTC" });
|
| 714 |
+
return `${f(end - 89 * day)} – ${f(end)}`;
|
| 715 |
+
}
|
| 716 |
|
| 717 |
function renderModalityChips() {
|
| 718 |
const box = document.getElementById("modality-chips");
|
|
|
|
| 742 |
// Ranked by growth vs a year ago, so small fast-growing modalities aren't buried under text and tabular.
|
| 743 |
function renderModality() {
|
| 744 |
const mod = modality;
|
|
|
|
|
|
|
| 745 |
const rows = D.modalityTotals.map((d) => {
|
| 746 |
const v = mod.values[d.name];
|
| 747 |
+
return { name: d.name, total: d.value, v, last3: d.last90, prev3: d.prev90, ago3: d.ago90 };
|
| 748 |
}).filter((r) => r.last3 > 0).sort((a, b) => (b.ago3 ? b.last3 / b.ago3 : Infinity) - (a.ago3 ? a.last3 / a.ago3 : Infinity));
|
| 749 |
|
| 750 |
document.getElementById("modality-sub").textContent =
|
| 751 |
+
`New datasets tagged with each modality in the last 90 days (${windowLabel(0)}), ranked by growth vs the same 90 days a year earlier`;
|
| 752 |
const tb = table(document.getElementById("modality"), [
|
| 753 |
+
{ t: "Modality" }, { t: "Last 90 days", cls: "n" }, { t: "vs prior 90", cls: "n" }, { t: "vs year ago", cls: "n" },
|
| 754 |
{ t: "All time", cls: "n opt" }, { t: "Per month, last 24 months · own scale", cls: "opt" },
|
| 755 |
]);
|
| 756 |
const trends = [];
|
|
|
|
| 763 |
el("td", { class: "n opt dim", text: fmtC.format(r.total) }, tr);
|
| 764 |
trends.push([el("td", { class: "trend opt" }, tr), r]);
|
| 765 |
hoverRow(tr, r.name, [
|
| 766 |
+
{ label: windowLabel(0), value: fmtInt.format(r.last3), color: modColor(r.name) },
|
| 767 |
+
{ label: windowLabel(90), value: fmtInt.format(r.prev3) },
|
| 768 |
+
{ label: windowLabel(365), value: fmtInt.format(r.ago3) },
|
| 769 |
{ label: "All time", value: fmtInt.format(r.total) },
|
| 770 |
]);
|
| 771 |
}
|
|
|
|
| 776 |
}
|
| 777 |
const best = rows.find((r) => r.ago3);
|
| 778 |
document.getElementById("modality-foot").textContent =
|
| 779 |
+
`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.`;
|
| 780 |
}
|
| 781 |
|
| 782 |
// ---------- activity table ----------
|
stats.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|