Show match demand in metrics (Refs #138)
CI / checks (push) Successful in 4m44s

This commit is contained in:
2026-10-10 16:26:32 -04:00
parent ea932ec563
commit 616b1937ed
15 changed files with 775 additions and 42 deletions
+17
View File
@@ -1,5 +1,22 @@
import type Database from 'better-sqlite3';
/** Match demand includes active and interrupted matches, independent of leaderboard eligibility. */
export function installMetricsMatchRevisions(handle: Database.Database) {
for (const table of ['leaderboard_matches', 'leaderboard_match_players'])
for (const action of ['INSERT', 'UPDATE', 'DELETE']) {
const fields =
table === 'leaderboard_matches' ? ['game', 'map_name', 'started_at'] : ['match_id'];
// Score/presence heartbeats do not change distinct participant counts.
const condition =
action === 'UPDATE'
? `WHEN ${fields.map((field) => `OLD.${field} IS NOT NEW.${field}`).join(' OR ')}`
: '';
handle.exec(`CREATE TRIGGER IF NOT EXISTS report_metrics_${table}_${action}
AFTER ${action} ON ${table} ${condition}
BEGIN UPDATE report_revisions SET revision=revision+1 WHERE topic='metrics'; END;`);
}
}
/** Current policy settings are inputs to historical metrics advice. */
export function installMetricsPolicyRevisions(handle: Database.Database) {
for (const table of ['autoscaling_policies', 'settings'])