-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { countAll } from '../db/util' | ||
import { MigrateDb, getDb } from './db' | ||
|
||
const run = async () => { | ||
const db = getDb() | ||
const results = await Promise.all([ | ||
totalCount(db), | ||
failureCount(db), | ||
failedBlobs(db), | ||
failedPrefs(db), | ||
failedTakedowns(db), | ||
]) | ||
console.log(` | ||
Total migrations: ${results[0]} | ||
Failed migrations: ${results[1]} | ||
Failed blobs: ${results[2]} | ||
Failed prefs: ${results[3]} | ||
Failed takedowns: ${results[4]} | ||
`) | ||
} | ||
|
||
const totalCount = async (db: MigrateDb) => { | ||
const res = await db | ||
.selectFrom('status') | ||
.select(countAll.as('count')) | ||
.executeTakeFirst() | ||
return res?.count | ||
} | ||
|
||
const failureCount = async (db: MigrateDb) => { | ||
const res = await db | ||
.selectFrom('status') | ||
.select(countAll.as('count')) | ||
.where('failed', '=', 1) | ||
.executeTakeFirst() | ||
return res?.count | ||
} | ||
|
||
const failedBlobs = async (db: MigrateDb) => { | ||
const res = await db | ||
.selectFrom('failed_blob') | ||
.select(countAll.as('count')) | ||
.executeTakeFirst() | ||
return res?.count | ||
} | ||
|
||
const failedPrefs = async (db: MigrateDb) => { | ||
const res = await db | ||
.selectFrom('failed_pref') | ||
.select(countAll.as('count')) | ||
.executeTakeFirst() | ||
return res?.count | ||
} | ||
|
||
const failedTakedowns = async (db: MigrateDb) => { | ||
const res = await db | ||
.selectFrom('failed_takedown') | ||
.select(countAll.as('count')) | ||
.executeTakeFirst() | ||
return res?.count | ||
} | ||
|
||
run() |