grantforge-api / backend /scripts /full_catalog_cron.py
GrantForge Bot
Deploy sha-9a5957fcdef15b7e2623f8b147cda6026475aee0 — source build (no GHCR)
3a3734f
Raw
History Blame Contribute Delete
1.23 kB
#!/usr/bin/env python3
"""Cron: import WYSZUKIWARKA → weryfikacja URL → ingest regulaminów."""
import asyncio
import logging
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from core.grants.sync_service import sync_grants_to_db
from core.subscription.db import SessionLocal
from core.grants.catalog_freshness import verify_catalog_grants
from core.grants.regulation_ingest import ingest_regulations_from_catalog
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
async def main():
db = SessionLocal()
try:
logger.info("[FullCatalogCron] sync_grants_to_db...")
sync_result = await sync_grants_to_db(db=db)
logger.info("[FullCatalogCron] sync: %s", sync_result)
verify = await verify_catalog_grants(db, limit=int(os.getenv("CATALOG_VERIFY_LIMIT", "200")))
logger.info("[FullCatalogCron] verify: %s", verify)
ingest = await ingest_regulations_from_catalog(
db, limit=int(os.getenv("REGULATION_INGEST_LIMIT", "60"))
)
logger.info("[FullCatalogCron] regulations: %s", ingest)
finally:
db.close()
if __name__ == "__main__":
asyncio.run(main())