fix: show current month data and add caching (#2573)

### Summary

- Add Cache-Control headers to all route responses (1h s-maxage, 2h
stale-while-revalidate)
- Append current month to chart data so graphs stay up-to-date
(cumulative carries forward, else zero)
- Remove `.limit(12)` from growth queries for full history
- Pass isCumulative flag through addZeroMonth
- Deduplicate TransformedData type, remove transformRepoStats
This commit is contained in:
Ephraim Duncan
2026-03-06 02:30:31 +00:00
committed by GitHub
parent c63b4ca3cc
commit 7e2cbe46c0
20 changed files with 50 additions and 49 deletions
+3 -14
View File
@@ -1,6 +1,6 @@
import { DateTime } from 'luxon';
import { addZeroMonth } from './add-zero-month';
import { type TransformedData, addZeroMonth } from './add-zero-month';
type MetricKeys = {
stars: number;
@@ -14,14 +14,6 @@ type DataEntry = {
[key: string]: MetricKeys;
};
type TransformData = {
labels: string[];
datasets: {
label: string;
data: number[];
}[];
};
type MetricKey = keyof MetricKeys;
const FRIENDLY_METRIC_NAMES: { [key in MetricKey]: string } = {
@@ -38,7 +30,7 @@ export function transformData({
}: {
data: DataEntry;
metric: MetricKey;
}): TransformData {
}): TransformedData {
try {
if (!data || Object.keys(data).length === 0) {
return {
@@ -103,7 +95,7 @@ export function transformData({
],
};
return addZeroMonth(transformedData);
return addZeroMonth(transformedData, true);
} catch (error) {
return {
labels: [],
@@ -111,6 +103,3 @@ export function transformData({
};
}
}
// To be on the safer side
export const transformRepoStats = transformData;