25 lines
1.0 KiB
Python
25 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Background sync with live progress tracking."""
|
|
import time
|
|
from app.export_intel_sync import sync_customers, sync_missing_countries
|
|
from app.export_intel_sync_progress import finish_job, job_step, start_job
|
|
|
|
REGIONS = ["europe", "middle_east", "gcc", "africa", "americas", "caribbean", "asia", "oceania"]
|
|
|
|
def main():
|
|
job_id = start_job("background", "Volledige wereld-update", total=len(REGIONS) + 1)
|
|
try:
|
|
job_step(job_id, message="Lege landen synchroniseren…", step="missing", current=0, total=len(REGIONS) + 1)
|
|
sync_missing_countries(max_priority=3)
|
|
for i, region in enumerate(REGIONS, start=1):
|
|
job_step(job_id, message=f"Horeca regio {i}/{len(REGIONS)}: {region}", step="horeca", current=i, total=len(REGIONS) + 1)
|
|
sync_customers(region_code=region)
|
|
time.sleep(2)
|
|
finish_job(job_id, result={"regions": len(REGIONS)})
|
|
except Exception as exc:
|
|
finish_job(job_id, error=str(exc))
|
|
raise
|
|
|
|
if __name__ == "__main__":
|
|
main()
|