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`.
- Fix isort 6.0.0 compatibility.

Co-Authored-by: Pascal Repond <[email protected]>
  • Loading branch information
PascalRepond committed Feb 4, 2025
1 parent 9d7de8c commit 52f6b2b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
23 changes: 17 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion rero_ils/modules/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

"""RERO ILS Record serialization."""

from invenio_records_rest.serializers.response import record_responsify
from invenio_records_rest.serializers.response import (
record_responsify
)
from invenio_records_rest.serializers.response import (
search_responsify as _search_responsify,
)
Expand Down
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
4 changes: 3 additions & 1 deletion rero_ils/modules/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
manage_role_permissions,
)
from .permissions import permission_management as permission_management_action
from .permissions import record_permissions
from .permissions import (
record_permissions
)

api_blueprint = Blueprint("api_blueprint", __name__, url_prefix="")

Expand Down
4 changes: 3 additions & 1 deletion tests/ui/patron_transactions/test_patron_transactions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

import pytest

from rero_ils.modules.patron_transactions.api import PatronTransaction
from rero_ils.modules.patron_transactions.api import (
PatronTransaction
)
from rero_ils.modules.patron_transactions.api import (
patron_transaction_id_fetcher as fetcher,
)
Expand Down

0 comments on commit 52f6b2b

Please sign in to comment.