Skip to content

Commit

Permalink
fix(stats): Delete aggregations for time frame before creating new on…
Browse files Browse the repository at this point in the history
…es so that the aggregating operation is idempotent
  • Loading branch information
monotasker committed Sep 13, 2024
1 parent 24ea7e5 commit 9e558e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions invenio_record_importer/services/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,14 @@ def create_stats_aggregations(
"""

aggregation_types = list(current_stats.aggregations)

# first delete existing aggregations
for a in aggregation_types:
aggr_cfg = current_stats.aggregations[a]
aggregator = aggr_cfg.cls(name=aggr_cfg.name, **aggr_cfg.params)
aggregator.delete(start_date, end_date)

# now create new aggregations
agg_task = aggregate_events.si(
aggregation_types,
start_date=(
Expand Down

0 comments on commit 9e558e7

Please sign in to comment.