Skip to content

Commit

Permalink
[PP-2109] Remove loan expiration events.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbernstein committed Feb 26, 2025
1 parent 44d9910 commit 78e70ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
22 changes: 10 additions & 12 deletions src/palace/manager/api/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,6 @@ def where_clause(self):
)
return ~self.MODEL_CLASS.id.in_(source_of_truth_subquery)

def delete(self, row) -> None:
ce = CirculationEvent
event_type = ce.CM_LOAN_EXPIRED if isinstance(row, Loan) else ce.CM_HOLD_EXPIRED
event = dict(
library=row.library,
license_pool=row.license_pool,
event_type=event_type,
patron=row.patron,
)
super().delete(row)
self._events_to_be_logged.append(event)

def after_commit(self) -> None:
super().after_commit()
copy_of_list = list(self._events_to_be_logged)
Expand Down Expand Up @@ -130,6 +118,16 @@ def where_clause(self):
)
return and_(superclause, probably_abandoned)

def delete(self, row) -> None:
event = dict(
library=row.library,
license_pool=row.license_pool,
event_type=CirculationEvent.CM_HOLD_EXPIRED,
patron=row.patron,
)
super().delete(row)
self._events_to_be_logged.append(event)


ReaperMonitor.REGISTRY.append(HoldReaper)

Expand Down
1 change: 0 additions & 1 deletion src/palace/manager/sqlalchemy/model/circulationevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class CirculationEvent(Base):
CM_HOLD_RELEASE = "circulation_manager_hold_release"
CM_HOLD_EXPIRED = "circulation_manager_hold_expired"
CM_HOLD_READY_FOR_CHECKOUT = "circulation_manager_hold_ready"
CM_LOAN_EXPIRED = "circulation_manager_loan_expired"
CM_HOLD_CONVERTED_TO_LOAN = "circulation_manager_hold_converted_to_loan"
CM_LOAN_CONVERTED_TO_HOLD = "circulation_manager_loan_converted_to_hold"
CM_FULFILL = "circulation_manager_fulfill"
Expand Down
4 changes: 1 addition & 3 deletions tests/manager/api/test_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,9 @@ def test_reaping(
call_args_list = (
services_fixture.analytics_fixture.analytics_mock.collect_event.call_args_list
)
assert len(call_args_list) == 4
assert len(call_args_list) == 2
event_types = [call_args.kwargs["event_type"] for call_args in call_args_list]
assert event_types == [
CirculationEvent.CM_LOAN_EXPIRED,
CirculationEvent.CM_LOAN_EXPIRED,
CirculationEvent.CM_HOLD_EXPIRED,
CirculationEvent.CM_HOLD_EXPIRED,
]
Expand Down

0 comments on commit 78e70ed

Please sign in to comment.