/** * Check most recent records in OptionsFlow_monthly */ import { rawQuery } from '../src/db.js'; import dotenv from 'dotenv'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); dotenv.config({ path: join(__dirname, '..', '.env') }); async function checkRecentRecords() { console.log('šŸ” Checking most recent records...\n'); try { // Get most recent records const recent = await rawQuery(` SELECT "CreatedDate", "CreatedTime", "Symbol", "CallPut", "Premium", "Strike" FROM "OptionsFlow_monthly" ORDER BY "CreatedDate" DESC, "CreatedTime" DESC LIMIT 20 `); console.log(`šŸ“Š Most recent ${recent.length} records:\n`); recent.forEach((r, i) => { console.log(`${i + 1}. ${r.CreatedDate} ${r.CreatedTime || ''} | ${r.Symbol} ${r.CallPut} ${r.Strike || ''} | Premium: ${r.Premium}`); }); // Get count by date const byDate = await rawQuery(` SELECT "CreatedDate", COUNT(*) as count FROM "OptionsFlow_monthly" GROUP BY "CreatedDate" ORDER BY "CreatedDate" DESC LIMIT 10 `); console.log('\nšŸ“… Records by date (most recent first):'); byDate.forEach(r => { console.log(` ${r.CreatedDate}: ${r.count} records`); }); // Get total count const total = await rawQuery('SELECT COUNT(*) as count FROM "OptionsFlow_monthly"'); console.log(`\nšŸ“Š Total records: ${total[0].count}`); } catch (error) { console.error('āŒ Error:', error.message); process.exit(1); } } checkRecentRecords();