Admin: Suche, Filter und Archiv in der Matchliste, Fehler direkt in der Karte
This commit is contained in:
1 parent
c50741e49c
commit
7ae3efef60
9 files changed
+206
-12
No files matched your search
@@ -625,6 +625,34 @@ export class MatchService extends EventEmitter {
|
||||
.run(matchId, match.current_map_number);
|
||||
}
|
||||
|
||||
/** Abgeschlossenes Match ins Archiv legen bzw. zurückholen. */
|
||||
setArchived(matchId, archived) {
|
||||
const match = this.getMatch(matchId);
|
||||
if (archived && !CLOSED_STATUSES.includes(match.status)) {
|
||||
throw new HttpError(409, 'Nur abgeschlossene oder abgebrochene Matches lassen sich archivieren', 'not_closed');
|
||||
}
|
||||
this.db.prepare('UPDATE matches SET archived_at = ? WHERE id = ?').run(archived ? this.now() : null, matchId);
|
||||
this.log(matchId, 'status', archived ? 'Match archiviert (Admin)' : 'Match aus dem Archiv geholt (Admin)');
|
||||
this.changed(matchId);
|
||||
}
|
||||
|
||||
/** Abgeschlossene Matches nach `archiveAfterDays` Tagen automatisch archivieren. Liefert die Anzahl. */
|
||||
archiveClosed(now = this.now()) {
|
||||
const days = this.config.archiveAfterDays;
|
||||
if (!days) return 0;
|
||||
const cutoff = now - days * 86_400_000;
|
||||
const ids = this.db.prepare(`
|
||||
SELECT id FROM matches
|
||||
WHERE archived_at IS NULL AND status IN ('finished', 'cancelled') AND COALESCE(finished_at, updated_at) < ?
|
||||
`).all(cutoff).map((r) => r.id);
|
||||
const stmt = this.db.prepare('UPDATE matches SET archived_at = ? WHERE id = ?');
|
||||
for (const id of ids) {
|
||||
stmt.run(now, id);
|
||||
this.log(id, 'status', `Match automatisch archiviert (nach ${days} Tagen)`);
|
||||
}
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
close(viewer, status) {
|
||||
this.require(viewer, 'organizer');
|
||||
this.closeMatch(viewer.matchId, status);
|
||||
@@ -881,6 +909,8 @@ export class MatchService extends EventEmitter {
|
||||
status: match.status,
|
||||
statusLabel: MATCH_STATUS[match.status],
|
||||
createdAt: match.created_at,
|
||||
finishedAt: match.finished_at ?? null,
|
||||
archivedAt: match.archived_at ?? null,
|
||||
updatedAt: match.updated_at,
|
||||
vetoStart: match.veto_start,
|
||||
currentMapNumber: match.current_map_number,
|
||||
|
||||
Reference in new issue
Block a user