From 124f34d25a948e0c6691e6bea7a9ac8547b85605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Wed, 11 Oct 2023 15:14:57 +0200 Subject: [PATCH] recalculate_charts: recalculate also blank presets --- CHANGELOG.rst | 1 + .../management/commands/recalculate_charts.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3caf46bb..5b737063 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,7 @@ Changelog * values in divided chart now are filtered by other criteria choices * removed support for other JSONFields than Django's native JSONField, removed ADMIN_CHARTS_USE_JSONFIELD setting * admin charts are loaded by JS including chart controls for quicker admin index load +* --time-until option was added to the `recalculate_charts` management command to recalculate charts only until given date 1.3.1 (2024-04-12) ------------------ diff --git a/admin_tools_stats/management/commands/recalculate_charts.py b/admin_tools_stats/management/commands/recalculate_charts.py index 1e41e15b..875dd76f 100644 --- a/admin_tools_stats/management/commands/recalculate_charts.py +++ b/admin_tools_stats/management/commands/recalculate_charts.py @@ -106,11 +106,13 @@ def handle(self, *args, **options): time_scales = stats.allowed_time_scales chart_tz = get_charts_timezone() - for operation_field in stats.operation_field_name.split(","): + operation_fields = stats.operation_field_name.split(",") + [""] + + for operation_field in operation_fields: for selected_interval in time_scales: print( - f"recalculating chart {stats} with {multiseries_criteria} on " - f"{operation_field} criteria in {selected_interval}" + f"recalculating chart '{stats}' with '{multiseries_criteria}' on " + f"'{operation_field}' criteria in {selected_interval}" ) time_since = datetime.now() - timedelta( days=stats.default_time_period