Skip to content

Commit

Permalink
fix(Django): split OFF product sync into 4 flavors. ref #376
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Sep 24, 2024
1 parent 87b6e21 commit 4fab7b8
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions open_prices/common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 4fab7b8

Please sign in to comment.