const { pool } = require('./src/db');

(async () => {
  const r = await pool.query(
    'SELECT c.id, c.crawled_at, c.site_name, ca.position, ca.casino_name FROM crawls c JOIN casinos ca ON ca.crawl_id = c.id WHERE c.id >= 320 ORDER BY c.id DESC, position LIMIT 40'
  );
  
  for (const row of r.rows) {
    const dt = new Date(row.crawled_at).toISOString().split('T')[1].substring(0, 5);
    const pos = String(row.position).padStart(2);
    console.log(dt, '|', row.site_name.padEnd(25), '#', pos, ':', row.casino_name);
  }
  
  await pool.end();
  process.exit(0);
})();
