fix: refresh existing monthly metrics snapshots

This commit is contained in:
Affaan Mustafa
2026-04-05 15:15:56 -07:00
parent 05acc27530
commit bf5961e8d1

View File

@@ -30,6 +30,10 @@ jobs:
return match ? Number(match[1]) : null;
}
function escapeRegex(value) {
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function fmt(value) {
if (value === null || value === undefined) return "n/a";
return Number(value).toLocaleString("en-US");
@@ -167,14 +171,17 @@ jobs:
}
const currentBody = issue.body || "";
if (currentBody.includes(`| ${monthKey} |`)) {
console.log(`Issue #${issue.number} already has snapshot row for ${monthKey}`);
return;
}
const rowPattern = new RegExp(`^\\| ${escapeRegex(monthKey)} \\|.*$`, "m");
const body = currentBody.includes("| Month (UTC) |")
? `${currentBody.trimEnd()}\n${row}\n`
: `${intro}\n${row}\n`;
let body;
if (rowPattern.test(currentBody)) {
body = currentBody.replace(rowPattern, row);
console.log(`Refreshed issue #${issue.number} snapshot row for ${monthKey}`);
} else {
body = currentBody.includes("| Month (UTC) |")
? `${currentBody.trimEnd()}\n${row}\n`
: `${intro}\n${row}\n`;
}
await github.rest.issues.update({
owner,