Skip to content

Commit

Permalink
Remove Library.all_collections property. (#2191)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdilauro authored Nov 26, 2024
1 parent b5b0522 commit 307a727
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/palace/manager/api/admin/controller/custom_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _get_work_from_urn(self, library: Library, urn: str | None) -> Work | None:
.join(LicensePool, LicensePool.work_id == Work.id)
.join(Collection, LicensePool.collection_id == Collection.id)
.filter(LicensePool.identifier_id == identifier.id)
.filter(Collection.id.in_([c.id for c in library.all_collections]))
.filter(Collection.id.in_([c.id for c in library.collections]))
)
work = query.one()
return work
Expand Down
4 changes: 1 addition & 3 deletions src/palace/manager/api/admin/dashboard_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ def _authorized_collections(
all_collections = self._all_collections()

for library in authorized_libraries:
library_collections = {
all_collections[c.id] for c in library.all_collections
}
library_collections = {all_collections[c.id] for c in library.collections}
authorized_collections_by_library[library.short_name] = sorted(
library_collections, key=lambda c: c.id
)
Expand Down
8 changes: 1 addition & 7 deletions src/palace/manager/sqlalchemy/model/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,6 @@ def update_settings(self, new_settings: LibrarySettings) -> None:
self._settings = None
integration_settings_update(LibrarySettings, self, new_settings, merge=True)

@property
def all_collections(self) -> Generator[Collection]:
for collection in self.collections:
yield collection
yield from collection.parents

@property
def entrypoints(self) -> Generator[type[EntryPoint] | None]:
"""The EntryPoints enabled for this library."""
Expand Down Expand Up @@ -394,7 +388,7 @@ def restrict_to_ready_deliverable_works(
from palace.manager.sqlalchemy.model.collection import Collection

collection_ids = collection_ids or [
x.id for x in self.all_collections if x.id is not None
x.id for x in self.collections if x.id is not None
]
return Collection.restrict_to_ready_deliverable_works(
query,
Expand Down
3 changes: 1 addition & 2 deletions tests/manager/sqlalchemy/model/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ def test_has_root_lanes(self, db: DatabaseTransactionFixture):
db.session.flush()
assert False == library.has_root_lanes

def test_all_collections(self, db: DatabaseTransactionFixture):
def test_collections(self, db: DatabaseTransactionFixture):
library = db.default_library()

parent = db.collection()
db.default_collection().parent_id = parent.id

assert [db.default_collection()] == library.collections
assert {db.default_collection(), parent} == set(library.all_collections)

def test_estimated_holdings_by_language(self, db: DatabaseTransactionFixture):
library = db.default_library()
Expand Down

0 comments on commit 307a727

Please sign in to comment.