#!/usr/bin/env python3 """ Check ENS Profiles This script checks how many contacts have ENS names and profile information. Usage: python check_ens_profiles.py """ import os import sys from dotenv import load_dotenv # Add parent directory to path to import utils sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from utils.db_connector import DatabaseConnector from utils.logger import setup_logger # Load environment variables load_dotenv() # Setup logging logger = setup_logger("check_ens_profiles") def check_ens_profiles(): """ Check how many contacts have ENS names and profile information. """ db = DatabaseConnector() # Check total contacts query = 'SELECT COUNT(*) as count FROM "Contact"' result = db.execute_query(query) total_contacts = result[0]["count"] logger.info(f"Total contacts: {total_contacts:,}") # Check contacts with ENS names query = 'SELECT COUNT(*) as count FROM "Contact" WHERE "ensName" IS NOT NULL' result = db.execute_query(query) contacts_with_ens = result[0]["count"] logger.info(f"Contacts with ENS names: {contacts_with_ens:,} ({contacts_with_ens/total_contacts*100:.1f}%)") # Check contacts with Twitter query = 'SELECT COUNT(*) as count FROM "Contact" WHERE "twitter" IS NOT NULL' result = db.execute_query(query) contacts_with_twitter = result[0]["count"] logger.info(f"Contacts with Twitter: {contacts_with_twitter:,} ({contacts_with_twitter/total_contacts*100:.1f}%)") # Check contacts with Email query = 'SELECT COUNT(*) as count FROM "Contact" WHERE "email" IS NOT NULL' result = db.execute_query(query) contacts_with_email = result[0]["count"] logger.info(f"Contacts with Email: {contacts_with_email:,} ({contacts_with_email/total_contacts*100:.1f}%)") # Check contacts with Farcaster query = 'SELECT COUNT(*) as count FROM "Contact" WHERE "farcaster" IS NOT NULL' result = db.execute_query(query) contacts_with_farcaster = result[0]["count"] logger.info(f"Contacts with Farcaster: {contacts_with_farcaster:,} ({contacts_with_farcaster/total_contacts*100:.1f}%)") # Check contacts with Discord query = 'SELECT COUNT(*) as count FROM "Contact" WHERE "discord" IS NOT NULL' result = db.execute_query(query) contacts_with_discord = result[0]["count"] logger.info(f"Contacts with Discord: {contacts_with_discord:,} ({contacts_with_discord/total_contacts*100:.1f}%)") # Check contacts with Telegram query = 'SELECT COUNT(*) as count FROM "Contact" WHERE "telegram" IS NOT NULL' result = db.execute_query(query) contacts_with_telegram = result[0]["count"] logger.info(f"Contacts with Telegram: {contacts_with_telegram:,} ({contacts_with_telegram/total_contacts*100:.1f}%)") # Check contacts with Other Social query = 'SELECT COUNT(*) as count FROM "Contact" WHERE "otherSocial" IS NOT NULL' result = db.execute_query(query) contacts_with_other_social = result[0]["count"] logger.info(f"Contacts with Other Social: {contacts_with_other_social:,} ({contacts_with_other_social/total_contacts*100:.1f}%)") # Check contacts with any profile information query = ''' SELECT COUNT(*) as count FROM "Contact" WHERE "twitter" IS NOT NULL OR "email" IS NOT NULL OR "farcaster" IS NOT NULL OR "discord" IS NOT NULL OR "telegram" IS NOT NULL OR "otherSocial" IS NOT NULL ''' result = db.execute_query(query) contacts_with_any_profile = result[0]["count"] logger.info(f"Contacts with any profile information: {contacts_with_any_profile:,} ({contacts_with_any_profile/total_contacts*100:.1f}%)") # Check contacts with ENS names but no profile information query = ''' SELECT COUNT(*) as count FROM "Contact" WHERE "ensName" IS NOT NULL AND "twitter" IS NULL AND "email" IS NULL AND "farcaster" IS NULL AND "discord" IS NULL AND "telegram" IS NULL AND "otherSocial" IS NULL ''' result = db.execute_query(query) contacts_with_ens_no_profile = result[0]["count"] logger.info(f"Contacts with ENS names but no profile information: {contacts_with_ens_no_profile:,} ({contacts_with_ens_no_profile/contacts_with_ens*100:.1f}%)") # List a few contacts with ENS names but no profile information query = ''' SELECT id, "ethereumAddress", "ensName" FROM "Contact" WHERE "ensName" IS NOT NULL AND "twitter" IS NULL AND "email" IS NULL AND "farcaster" IS NULL AND "discord" IS NULL AND "telegram" IS NULL AND "otherSocial" IS NULL LIMIT 5 ''' result = db.execute_query(query) if result: logger.info("Examples of contacts with ENS names but no profile information:") for contact in result: logger.info(f" {contact['ensName']} ({contact['ethereumAddress']})") if __name__ == "__main__": check_ens_profiles()