All checks were successful
deploy / deploy (push) Successful in 48s
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
47 lines
2.8 KiB
JavaScript
47 lines
2.8 KiB
JavaScript
import { createPostgresPool } from './src/lib/postgres.mjs';
|
|
import { loadConfig } from './src/lib/config.mjs';
|
|
import * as pg from './src/lib/postgres.mjs';
|
|
|
|
async function main() {
|
|
const config = loadConfig();
|
|
const pool = pg.createPostgresPool({ connectionString: config.postgresUrl });
|
|
|
|
const fns = [
|
|
{ name: 'loadLatestPortfolioMetric', fn: () => pg.loadLatestPortfolioMetric(pool) },
|
|
{ name: 'loadLatestInventorySnapshot', fn: () => pg.loadLatestInventorySnapshot(pool) },
|
|
{ name: 'loadLatestMarketPrice', fn: () => pg.loadLatestMarketPrice(pool) },
|
|
{ name: 'loadRecentQuotes', fn: () => pg.loadRecentQuotes(pool, { limit: 100 }) },
|
|
{ name: 'loadSubmissionSummary', fn: () => pg.loadSubmissionSummary(pool) },
|
|
{ name: 'loadSubmissionPage', fn: () => pg.loadSubmissionPage(pool, { page: 1, pageSize: 20 }) },
|
|
{ name: 'loadCurrentFundingObservations', fn: () => pg.loadCurrentFundingObservations(pool) },
|
|
{ name: 'loadRecentDepositStatuses', fn: () => pg.loadRecentDepositStatuses(pool, { limit: 20 }) },
|
|
{ name: 'loadRecentTradeDecisions', fn: () => pg.loadRecentTradeDecisions(pool, { limit: 20 }) },
|
|
{ name: 'loadRecentExecuteTradeCommands', fn: () => pg.loadRecentExecuteTradeCommands(pool, { limit: 40 }) },
|
|
{ name: 'loadRecentExecutionResults', fn: () => pg.loadRecentExecutionResults(pool, { limit: 40 }) },
|
|
{ name: 'loadRecentQuoteOutcomes', fn: () => pg.loadRecentQuoteOutcomes(pool, { limit: 200 }) },
|
|
{ name: 'loadSuccessfulQuoteLifecycleEvidence', fn: () => pg.loadSuccessfulQuoteLifecycleEvidence(pool, { limit: 50 }) },
|
|
{ name: 'loadQuoteLifecycleRetentionSummary', fn: () => pg.loadQuoteLifecycleRetentionSummary(pool) },
|
|
{ name: 'loadRecentQuoteLifecycleRollups', fn: () => pg.loadRecentQuoteLifecycleRollups(pool, { limit: 40 }) },
|
|
{ name: 'loadQuoteLifecycleStatistics', fn: () => pg.loadQuoteLifecycleStatistics(pool, { limit: 1000 }) },
|
|
{ name: 'loadRecentIntentRequests', fn: () => pg.loadRecentIntentRequests(pool, { limit: 20, btcAsset: config.tradingBtc, eureAsset: config.tradingEure, refreshOutcomes: false }) },
|
|
{ name: 'loadRecentAlertTransitions', fn: () => pg.loadRecentAlertTransitions(pool, { limit: 20 }) },
|
|
{ name: 'loadRecentEnvironmentStatuses', fn: () => pg.loadRecentEnvironmentStatuses(pool, { limit: 20 }) },
|
|
{ name: 'loadAssetCatalogSummary', fn: () => pg.loadAssetCatalogSummary(pool, { limit: 250 }) },
|
|
{ name: 'loadPairConfigSummary', fn: () => pg.loadPairConfigSummary(pool) },
|
|
];
|
|
|
|
for (const { name, fn } of fns) {
|
|
const start = Date.now();
|
|
try {
|
|
await fn();
|
|
const duration = Date.now() - start;
|
|
console.log(`${name}: ${duration}ms`);
|
|
} catch (err) {
|
|
console.error(`${name}: ERROR ${err.message}`);
|
|
}
|
|
}
|
|
|
|
pool.end();
|
|
}
|
|
|
|
main().catch(console.error);
|