blob: 8084e030b11c63efaa94f6c7e105e651471bfbe5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#!/bin/bash
# Clean out stale games from the database.
WHERE_TIMEOUT_OPEN="WHERE status = 0 AND mtime < datetime('now', '-7 days')"
WHERE_TIMEOUT_ACTIVE="WHERE status = 1 AND mtime < datetime('now', '-14 days')"
echo "--- TIMED OUT OPEN GAMES ---"
sqlite3 db "SELECT * FROM game_view $WHERE_TIMEOUT_OPEN"
sqlite3 db "DELETE FROM games $WHERE_TIMEOUT_OPEN"
echo "--- TIMED OUT ACTIVE GAMES ---"
sqlite3 db "SELECT * FROM game_view $WHERE_TIMEOUT_ACTIVE"
sqlite3 db "UPDATE games SET status = 3 $WHERE_TIMEOUT_ACTIVE"
sqlite3 db "DELETE FROM replay WHERE game_id < 1346"
|