Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Lane saving #20

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/admin/controller/custom_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def _create_or_update_list(

# If this list was used to populate any lanes, those lanes need to have their counts updated.
for lane in Lane.affected_by_customlist(list):
lane.update_size(self._db, self.search_engine)
lane.update_size(self._db, search_engine=self.search_engine)

new_collections = []
for collection_id in collections:
Expand Down Expand Up @@ -399,7 +399,7 @@ def custom_list(self, list_id: int) -> Response | dict | ProblemDetail | None:
# Update the size for any lanes affected by this
# CustomList which _weren't_ deleted.
for lane in surviving_lanes:
lane.update_size(self._db, self.search_engine)
lane.update_size(self._db, search_engine=self.search_engine)
return Response(str(_("Deleted")), 200)

return None
Expand Down
2 changes: 1 addition & 1 deletion api/admin/controller/lanes.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def lanes_for_parent(parent):
for list in lane.customlists:
if list.id not in custom_list_ids:
lane.customlists.remove(list)
lane.update_size(self._db, self.search_engine)
lane.update_size(self._db, search_engine=self.search_engine)

if is_new:
return Response(str(lane.id), 201)
Expand Down
5 changes: 1 addition & 4 deletions core/lane.py
Original file line number Diff line number Diff line change
Expand Up @@ -2953,10 +2953,7 @@ def uses_customlists(self):
return True
return False

@inject
def update_size(
self, _db, search_engine: ExternalSearchIndex = Provide["search.index"]
):
def update_size(self, _db, search_engine: ExternalSearchIndex):
"""Update the stored estimate of the number of Works in this Lane."""
library = self.get_library(_db)

Expand Down