Fix stale match liveness and stop handling (Refs #136)
CI / checks (push) Successful in 5m15s
CI / checks (push) Successful in 5m15s
This commit is contained in:
@@ -67,7 +67,15 @@ export function recordLeaderboardTelemetry(handle: Database.Database, report: Ga
|
||||
'SELECT * FROM leaderboard_matches WHERE server = ? AND server_deleted_at IS NULL ORDER BY id DESC LIMIT 1'
|
||||
)
|
||||
.get(report.server) as Match | undefined;
|
||||
if (match?.last_fingerprint === signature && match.map_key === identity.key) return;
|
||||
if (match?.last_fingerprint === signature && match.map_key === identity.key) {
|
||||
// Unchanged gameplay still proves an open match is reporting. Keep the
|
||||
// duplicate from changing participation, counters, or completed results.
|
||||
if (match.status === 'active')
|
||||
handle
|
||||
.prepare('UPDATE leaderboard_matches SET last_received_at = ? WHERE id = ?')
|
||||
.run(report.receivedAt, match.id);
|
||||
if (match.status !== 'interrupted') return;
|
||||
}
|
||||
|
||||
const isStart = report.event === 'game_start';
|
||||
const round = isStart ? 0 : report.round;
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { readMatchQuery, type MatchHistoryQuery } from '../../match-history-query.js';
|
||||
|
||||
const matchSummary = `m.id, m.game, m.highest_round AS observedRound, m.server, m.server_deleted_at, m.map_name AS map, m.started_at AS startedAt, m.status,
|
||||
m.last_received_at AS lastReportedAt,
|
||||
CASE WHEN m.status = 'completed' THEN m.ended_at END AS endedAt,
|
||||
m.start_players AS startPlayers,
|
||||
(SELECT COUNT(*) FROM leaderboard_match_players p WHERE p.match_id = m.id) AS uniquePlayers,
|
||||
|
||||
@@ -1551,12 +1551,20 @@ async function processJob(job: Job, eligibility: (job: Job) => string | null) {
|
||||
hold(job, 'Waiting for the agent to verify a stopped container.');
|
||||
return;
|
||||
}
|
||||
db()
|
||||
.prepare(
|
||||
'UPDATE servers SET container_state=?,last_players=NULL,last_roster=NULL WHERE name=?'
|
||||
)
|
||||
.run(health.state, job.server);
|
||||
complete(job);
|
||||
db().transaction(() => {
|
||||
db()
|
||||
.prepare(
|
||||
'UPDATE servers SET container_state=?,last_players=NULL,last_roster=NULL WHERE name=?'
|
||||
)
|
||||
.run(health.state, job.server);
|
||||
db()
|
||||
.prepare(
|
||||
`UPDATE leaderboard_matches SET status='interrupted', ended_at=?
|
||||
WHERE server=? AND status='active' AND server_deleted_at IS NULL`
|
||||
)
|
||||
.run(containerObservedAt, job.server);
|
||||
complete(job);
|
||||
})();
|
||||
return;
|
||||
}
|
||||
check(
|
||||
|
||||
Reference in New Issue
Block a user