From 4fab7b8d0e5f6db8d9ab059f2d0f4ecbd58eb192 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Tue, 24 Sep 2024 11:53:17 +0200 Subject: [PATCH] fix(Django): split OFF product sync into 4 flavors. ref #376 --- open_prices/common/tasks.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/open_prices/common/tasks.py b/open_prices/common/tasks.py index 3466d545..838e5c01 100644 --- a/open_prices/common/tasks.py +++ b/open_prices/common/tasks.py @@ -17,12 +17,30 @@ from open_prices.users.models import User -def import_product_db_task(): +def import_off_db_task(): + import_product_db(flavor=Flavor.off) + + +def import_obf_db_task(): + import_product_db(flavor=Flavor.obf) + + +def import_opff_db_task(): + import_product_db(flavor=Flavor.opff) + + +def import_opf_db_task(): + import_product_db(flavor=Flavor.opf) + + +def import_all_product_db_task(): """ Sync product database with Open Food Facts """ - for flavor in [Flavor.off, Flavor.obf, Flavor.opff, Flavor.opf]: - import_product_db(flavor=flavor) + import_off_db_task() + import_obf_db_task() + import_opff_db_task() + import_opf_db_task() def update_user_counts_task(): @@ -50,7 +68,10 @@ def dump_db_task(): CRON_SCHEDULES = { - "import_product_db_task": "0 15 * * *", # daily at 15:00 + "import_obf_db_task": "0 15 * * *", # daily at 15:00 + "import_opff_db_task": "10 15 * * *", # daily at 15:10 + "import_opf_db_task": "20 15 * * *", # daily at 15:20 + "import_off_db_task": "30 15 * * *", # daily at 15:30 "update_user_counts_task": "0 2 * * 1", # every start of the week "dump_db_task": "0 23 * * *", # daily at 23:00 }