2026-04-10 18:37:33 +02:00
|
|
|
from typing import Any
|
|
|
|
|
|
2026-04-15 08:15:53 +02:00
|
|
|
from scrape_golfpakker import run_golfpakker_scraper
|
2026-04-10 18:37:33 +02:00
|
|
|
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
|
2026-04-12 10:11:23 +02:00
|
|
|
from scrape_utils import ProgressCallback
|
2026-04-10 18:37:33 +02:00
|
|
|
|
|
|
|
|
|
2026-04-12 10:11:23 +02:00
|
|
|
async def run_scrape_job(job: dict[str, Any], progress_callback: ProgressCallback | None = None) -> dict[str, Any]:
|
2026-04-10 18:37:33 +02:00
|
|
|
job_type = job["job_type"]
|
|
|
|
|
facility_ids = job.get("facility_ids") or []
|
|
|
|
|
|
|
|
|
|
if job_type == "banestatus":
|
2026-04-12 10:11:23 +02:00
|
|
|
result = await run_daily_scraping(facility_ids, progress_callback=progress_callback)
|
2026-04-10 18:37:33 +02:00
|
|
|
elif job_type == "medlemskap":
|
2026-04-12 10:11:23 +02:00
|
|
|
result = await run_membership_scraper(facility_ids, progress_callback=progress_callback)
|
2026-04-10 18:37:33 +02:00
|
|
|
elif job_type == "greenfee":
|
2026-04-12 10:11:23 +02:00
|
|
|
result = await run_greenfee_scraper(facility_ids, progress_callback=progress_callback)
|
2026-04-10 18:37:33 +02:00
|
|
|
elif job_type == "vtg":
|
2026-04-12 10:11:23 +02:00
|
|
|
result = await run_vtg_scraper(facility_ids, progress_callback=progress_callback)
|
2026-04-15 08:15:53 +02:00
|
|
|
elif job_type == "golfpakker":
|
|
|
|
|
result = await run_golfpakker_scraper(facility_ids, progress_callback=progress_callback)
|
2026-04-10 18:37:33 +02:00
|
|
|
else:
|
|
|
|
|
raise ValueError(f"Ukjent scrape-jobbtype: {job_type}")
|
|
|
|
|
|
|
|
|
|
return result or {}
|