Skip to content

Commit 5c9856b

Browse files
committed
stats: warn when loan gets indexed while loan-transitions index does not exist
* previously the loan indexing failed silently if the index `events-stats-loan-transitions` did not exist. * This only happens when no loan transition event was indexed yet.
1 parent ec52b93 commit 5c9856b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

invenio_app_ils/circulation/indexer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ def index_stats_fields_for_loan(loan_dict):
130130
# Document availability during loan request
131131
stat_events_index_name = "events-stats-loan-transitions"
132132
if current_search_client.indices.exists(index=stat_events_index_name):
133-
search_body = {}
134-
135133
loan_pid = loan_dict["pid"]
136134
search_body = {
137135
"query": {
@@ -161,6 +159,13 @@ def index_stats_fields_for_loan(loan_dict):
161159
f"Multiple request transition events for loan {loan_pid}."
162160
"Expected zero or one."
163161
)
162+
else:
163+
current_app.logger.error(
164+
"Stats events index '{stat_events_index_name}' does not exist. "
165+
"This is normal during initial setup or if no events have been processed yet. "
166+
"No data is lost, as soon as the events are processed, " \
167+
"the loan wil lbe reindex and the the stat will be available."
168+
)
164169

165170
if not "extra_data" in loan_dict:
166171
loan_dict["extra_data"] = {}

0 commit comments

Comments
 (0)