Nye-TeeOff/backend/scrape_job_runner.py

24 lines
828 B
Python
Executable file

from typing import Any
from scrape_greenfee import run_greenfee_scraper
from scrape_membership import run_scraper as run_membership_scraper
from scrape_status import run_daily_scraping
from scrape_vtg import run_vtg_scraper
async def run_scrape_job(job: dict[str, Any]) -> dict[str, Any]:
job_type = job["job_type"]
facility_ids = job.get("facility_ids") or []
if job_type == "banestatus":
result = await run_daily_scraping(facility_ids)
elif job_type == "medlemskap":
result = await run_membership_scraper(facility_ids)
elif job_type == "greenfee":
result = await run_greenfee_scraper(facility_ids)
elif job_type == "vtg":
result = await run_vtg_scraper(facility_ids)
else:
raise ValueError(f"Ukjent scrape-jobbtype: {job_type}")
return result or {}