"""Trigger full citation refresh directly on the database"""
import asyncio
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker
from app.services.pubmed_api import update_citation_counts

DATABASE_URL = 'postgresql+asyncpg://scilit:scilit_prod_2026@postgres:5432/scilit'

async def main():
    engine = create_async_engine(DATABASE_URL, pool_size=4)
    async_session = sessionmaker(engine, class_=AsyncSession)

    async with async_session() as db:
        result = await update_citation_counts(db, limit=5000)
        print(f"Updated: {result['updated']}, Total: {result['total']}, Errors: {result['errors']}")

    await engine.dispose()

asyncio.run(main())
