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

(async () => {
  const r = await pool.query(
    'SELECT DISTINCT casino_name FROM casinos WHERE LENGTH(TRIM(casino_name)) BETWEEN 3 AND 40 ORDER BY casino_name LIMIT 60'
  );

  var goodCount = 0;
  var junkCount = 0;

  for (const row of r.rows) {
    var name = row.casino_name || '';
    
    if (!name.match(/^[a-zA-Z]/)) continue;

    var ok = 
      (name.match(/[a-zA-Z]/g) || []).length / name.length > 0.4 &&
      !/(icon|dmca|bonus|spins|review>|»|banner)/i.test(name);

    if (ok) {
      console.log('✅ ' + name.replace(/[^a-zA-Z0-9\s&]/g, '').trim());
      goodCount++;
    } else {
      console.log('❌ STILL JUNK: ' + JSON.stringify(name));
      junkCount++;
    }
  }

  console.log('\nGood: ' + goodCount + ', Bad: ' + junkCount);

  await pool.end();
})();
