Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(stats): New daily CRON to update TotalStats #478

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions open_prices/common/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from open_prices.locations.models import Location
from open_prices.prices.models import Price
from open_prices.proofs.models import Proof
from open_prices.stats.models import TotalStats
from open_prices.users.models import User


Expand Down Expand Up @@ -43,6 +44,18 @@ def import_all_product_db_task():
import_opf_db_task()


def update_total_stats_task():
"""
Update all total stats
"""
total_stats = TotalStats.get_solo()
total_stats.update_price_stats()
total_stats.update_product_stats()
total_stats.update_location_stats()
total_stats.update_proof_stats()
total_stats.update_user_stats()


def update_user_counts_task():
"""
Update all user price_counts
Expand Down Expand Up @@ -81,6 +94,7 @@ def dump_db_task():
"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_total_stats_task": "0 1 * * *", # daily at 01:00
"update_user_counts_task": "0 2 * * 1", # every start of the week
"update_location_counts_task": "10 2 * * 1", # every start of the week
"dump_db_task": "0 23 * * *", # daily at 23:00
Expand Down