← back to Handbag Auth Nextjs

test-historical.js

22 lines

const Database = require('better-sqlite3');
const db = new Database('./data/handbags.db');

const result = db.prepare('SELECT id, brand, price_usd, historical_prices FROM listings WHERE historical_prices IS NOT NULL LIMIT 1').get();

if (result) {
  const hist = JSON.parse(result.historical_prices);
  console.log('✅ Database Verification');
  console.log('='.repeat(60));
  console.log(`Bag ID: ${result.id}`);
  console.log(`Brand: ${result.brand}`);
  console.log(`Current Price: $${result.price_usd.toLocaleString()}`);
  console.log(`\nHistorical Data Points: ${hist.length}`);
  console.log(`First: ${hist[0].year} - $${hist[0].price.toLocaleString()}`);
  console.log(`Last: ${hist[hist.length - 1].year} - $${hist[hist.length - 1].price.toLocaleString()}`);
  const appreciation = Math.round(((hist[hist.length - 1].price - hist[0].price) / hist[0].price) * 100);
  console.log(`Appreciation: +${appreciation}%`);
  console.log(`\nAll years: ${hist.map(h => h.year).join(', ')}`);
}

db.close();