Skip to content

Commit

Permalink
fix(stats): make active patrons period 12 months
Browse files Browse the repository at this point in the history
- The correct date range for number_of_active_patrons in the pricing stats
should be 12 months and not the default `RERO_ILS_STATS_BILLING_TIMEFRAME_IN_MONTHS`.

Co-Authored-by: Pascal Repond <[email protected]>
  • Loading branch information
PascalRepond committed Feb 4, 2025
1 parent 9d7de8c commit e1b3d28
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rero_ils/modules/stats/api/pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,16 @@ def number_of_active_patrons(self, library_pid):
:return: the number of matched active patrons
:rtype: integer
"""
_to = self.to_date.format(fmt="YYYY-MM-DDT23:59:59")
_from = (self.to_date - relativedelta(months=12)).format(
fmt="YYYY-MM-DDT00:00:00"
)
date_range = {"gte": _from, "lte": _to}
op_logs_query = (
LoanOperationLogsSearch()
.get_logs_by_trigger(
triggers=[ItemCirculationAction.CHECKOUT, ItemCirculationAction.EXTEND],
date_range=self.date_range,
date_range=date_range,
)
.filter("term", loan__item__library_pid=library_pid)
)
Expand Down

0 comments on commit e1b3d28

Please sign in to comment.