This commit is contained in:
@@ -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'])
|
||||
|
||||
Reference in New Issue
Block a user