fix: only sample wait times within each park's operating window
Build and Deploy / Build & Push (push) Successful in 1m5s
Build and Deploy / Build & Push (push) Successful in 1m5s
Queue-Times keeps reporting yesterday's last wait with isOpen=true overnight, so the per-ride open check wasn't enough — the sampler was recording phantom "open" samples between close and the next morning's first refresh, padding both wait-time averages and uptime% with stale data. Add isWithinOperatingWindow gate (same check the /rides route uses) so the sampler only runs during the park's actual hours plus the 1-hour closing buffer. Includes a one-off wipe script for the accumulated bad data. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* One-off cleanup: wipe ride history accumulated before the operating-window
|
||||
* gate was added to the sampler. Safe to re-run; truncates only the two
|
||||
* sample-related tables, leaves park_days untouched.
|
||||
*/
|
||||
import Database from "better-sqlite3";
|
||||
import path from "path";
|
||||
|
||||
const dbPath = path.join(__dirname, "..", "data", "parks.db");
|
||||
const db = new Database(dbPath);
|
||||
|
||||
const before = {
|
||||
samples: (db.prepare("SELECT COUNT(*) AS c FROM ride_wait_samples").get() as { c: number }).c,
|
||||
rides: (db.prepare("SELECT COUNT(*) AS c FROM rides").get() as { c: number }).c,
|
||||
};
|
||||
console.log("Before:", before);
|
||||
|
||||
db.exec("DELETE FROM ride_wait_samples; DELETE FROM rides;");
|
||||
|
||||
const after = {
|
||||
samples: (db.prepare("SELECT COUNT(*) AS c FROM ride_wait_samples").get() as { c: number }).c,
|
||||
rides: (db.prepare("SELECT COUNT(*) AS c FROM rides").get() as { c: number }).c,
|
||||
};
|
||||
console.log("After: ", after);
|
||||
|
||||
db.close();
|
||||
Reference in New Issue
Block a user