#!/usr/bin/env python3 """Check current data quality in cache.db""" import sqlite3 conn = sqlite3.connect('/mnt/okcomputer/output/cache.db') print("=" * 60) print("CURRENT DATA QUALITY CHECK") print("=" * 60) # Check lots table print("\n[*] Sample Lot Data:") cursor = conn.execute(""" SELECT lot_id, current_bid, bid_count, closing_time FROM lots LIMIT 10 """) for row in cursor: print(f" Lot: {row[0]}") print(f" Current Bid: {row[1]}") print(f" Bid Count: {row[2]}") print(f" Closing Time: {row[3]}") # Check auctions table print("\n[*] Sample Auction Data:") cursor = conn.execute(""" SELECT auction_id, title, closing_time, first_lot_closing_time FROM auctions LIMIT 5 """) for row in cursor: print(f" Auction: {row[0]}") print(f" Title: {row[1][:50]}...") print(f" Closing Time: {row[2] if len(row) > 2 else 'N/A'}") print(f" First Lot Closing: {row[3]}") # Data completeness stats print("\n[*] Data Completeness:") cursor = conn.execute(""" SELECT COUNT(*) as total, SUM(CASE WHEN current_bid IS NULL OR current_bid = '' THEN 1 ELSE 0 END) as missing_current_bid, SUM(CASE WHEN closing_time IS NULL OR closing_time = '' THEN 1 ELSE 0 END) as missing_closing_time, SUM(CASE WHEN bid_count IS NULL OR bid_count = 0 THEN 1 ELSE 0 END) as zero_bid_count FROM lots """) row = cursor.fetchone() print(f" Total lots: {row[0]:,}") print(f" Missing current_bid: {row[1]:,} ({100*row[1]/row[0]:.1f}%)") print(f" Missing closing_time: {row[2]:,} ({100*row[2]/row[0]:.1f}%)") print(f" Zero bid_count: {row[3]:,} ({100*row[3]/row[0]:.1f}%)") conn.close() print("\n" + "=" * 60)