diff --git a/app/services/spot_inspector.ts b/app/services/spot_inspector.ts index c72569c..60d18bc 100644 --- a/app/services/spot_inspector.ts +++ b/app/services/spot_inspector.ts @@ -16,7 +16,11 @@ const BATCH = 20 const IDLE_MS = 60_000 /** Unmatched spots are matched again this often (the header pass may have built their releases since). */ const REMATCH_MS = 60 * 60 * 1000 -/** Unmatched spots matched again per hour: after a reset every spot is (16.5k at 500 an hour took 33 h). */ +/** + * Unmatched spots matched again per hour: after a reset every spot is (16.5k at 500 an hour took 33 h). Never tried + * first, then the newest: the oldest inspection first tried a 3-month backfill before today's spots, the ones whose + * releases the tail has (2 of 16.7k matched 3 h after reset 24). + */ const REMATCH_BATCH = 5000 /** Unmatched spots are matched again for this long after their inspection. */ const REMATCH_DAYS = 30 @@ -297,7 +301,7 @@ export class SpotInspector { const { rows: spots } = await db.rawQuery( `SELECT message_id, inspected_at, release_id FROM spots WHERE status = 'inspected' AND matched = 0 AND inspected_at > now() - make_interval(days => ?) - ORDER BY coalesce(rematched_at, inspected_at) LIMIT ?`, + ORDER BY rematched_at NULLS FIRST, posted_at DESC NULLS LAST LIMIT ?`, [REMATCH_DAYS, REMATCH_BATCH] ) const cutoff = Date.now() - coordinatorConfig.spots.standaloneAfterHours * 3600 * 1000