unrip/fix-attributions-fast.mjs
philipp fb547f24d9
All checks were successful
deploy / deploy (push) Successful in 48s
fix: scope inventory fetch by submission time window to prevent OOM
Instead of fetching up to 50k inventory snapshots (~442MB), scope the
query to only the time range of the current submission batch with a
15-minute buffer. For a typical 1-hour batch this drops from 50k rows
to ~300 rows, well within the 1280Mi pod memory limit.

The coalesced_at_idx on intent_inventory_snapshots covers the BETWEEN
clause so this remains efficient.

Proof: history-writer OOM kills from refreshQuoteOutcomes inventory fetch
Assumptions: 15min buffer covers the attribution window for all submissions
Still fake: heuristic gap outcomes may attribute trades imprecisely
2026-06-16 17:17:19 +02:00

16 lines
651 B
JavaScript

import { createPostgresPool, refreshQuoteOutcomes } from './src/lib/postgres.mjs';
async function main() {
const pool = createPostgresPool({ connectionString: process.env.POSTGRES_URL });
console.log("Running refreshQuoteOutcomes with large limits to re-attribute historical trades...");
const records = await refreshQuoteOutcomes(pool, {
submissionLimit: 15000,
inventoryLimit: 50000,
});
console.log("Refreshed", records.length, "quotes.");
const completed = records.filter(r => r.outcome_status === 'completed');
console.log("Found", completed.length, "completed trades!");
process.exit(0);
}
main().catch(console.error);