feat: build compact BO2 grind companion with cumulative ranks
Some checks failed
Test and deploy staging / staging (push) Failing after 2m50s
Some checks failed
Test and deploy staging / staging (push) Failing after 2m50s
This commit is contained in:
33
scripts/audit-tracker-data.ts
Normal file
33
scripts/audit-tracker-data.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import postgres from 'postgres';
|
||||
|
||||
// Read-only fingerprints: lets a deployment verify saved progress without logging it.
|
||||
if (!process.env.DB_URL) throw new Error('DB_URL is required');
|
||||
const client = postgres(process.env.DB_URL, { max: 1 });
|
||||
const tables = [
|
||||
'user_entries',
|
||||
'user_games',
|
||||
'catch_em_all_settings',
|
||||
'pokemon_journeys',
|
||||
'pokemon_catches',
|
||||
'pokemon_milestones',
|
||||
'pokemon_seen',
|
||||
'tracker_progress',
|
||||
'tracker_ranks',
|
||||
'tracker_weapon_ranks',
|
||||
'tracker_challenge_progress',
|
||||
'osu_entries'
|
||||
];
|
||||
try {
|
||||
const result: Record<string, unknown> = {};
|
||||
for (const table of tables) {
|
||||
const [exists] = await client`select to_regclass(${'public.' + table}) is not null as present`;
|
||||
if (!exists.present) continue;
|
||||
const [row] = await client.unsafe(`select count(*)::int as rows,
|
||||
md5(coalesce(string_agg(record, E'\\n' order by record), '')) as fingerprint
|
||||
from (select row_to_json(t)::text as record from "${table}" t) s`);
|
||||
result[table] = row;
|
||||
}
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
} finally {
|
||||
await client.end();
|
||||
}
|
||||
Reference in New Issue
Block a user