cs-prices: price history backfill (Steam daily median since 2013 from the public listing page, CSFloat daily averages, ECB FX history) in separate *-history streams; labelled on item charts
All checks were successful
Deploy production / deploy (push) Successful in 1m13s

This commit is contained in:
2026-10-26 09:32:55 +00:00
parent 7396d23335
commit 76f063b362
5 changed files with 42972 additions and 2 deletions

View File

@@ -185,3 +185,21 @@ export const csFxRates = csSchema.table('fx_rates', {
day: date('day').primaryKey(),
usdEur: numeric('usd_eur', { precision: 12, scale: 8 }).notNull()
});
// Backfill bookkeeping (scripts/cs-history.ts): which config was fetched from which history
// source, so the slow, throttled backfill can resume. History rows themselves live in
// daily_prices under their own streams (kind ending in `-history`).
export const csHistoryFetches = csSchema.table(
'history_fetches',
{
itemId: integer('item_id')
.notNull()
.references(() => csMarketItems.id, { onDelete: 'cascade' }),
source: text('source').notNull(),
fetchedAt: timestamp('fetched_at', { withTimezone: true }).notNull().defaultNow(),
points: integer('points').notNull().default(0),
firstDay: date('first_day'),
error: text('error')
},
(table) => [primaryKey({ name: 'history_fetches_pkey', columns: [table.itemId, table.source] })]
);

View File

@@ -13,7 +13,9 @@
'steam-market:sale-avg': '#a855f7',
'steam-market:lowest-listing': '#d946ef',
'csfloat:lowest-listing': '#f59e0b',
'buff163:lowest-listing': '#ef4444'
'buff163:lowest-listing': '#ef4444',
'steam-market:sale-median-history': '#14b8a6',
'csfloat:sale-avg-history': '#f97316'
};
const sourceNames: Record<string, string> = {
skinport: 'Skinport',
@@ -24,7 +26,9 @@
const kindNames: Record<string, string> = {
'lowest-listing': 'lowest listing',
'sale-median-24h': 'sold, 24h median',
'sale-avg': 'sold, average'
'sale-avg': 'sold, average',
'sale-median-history': 'sold, daily median (history)',
'sale-avg-history': 'sold, daily average (history)'
};
const eur = new Intl.NumberFormat('nl-NL', { style: 'currency', currency: 'EUR' });
const usd = new Intl.NumberFormat('nl-NL', { style: 'currency', currency: 'USD' });