Skip to content

Commit

Permalink
Rename a couple more library/collection association properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdilauro committed Nov 26, 2024
1 parent aad0972 commit 15cafd5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/palace/manager/sqlalchemy/model/lane.py
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ def initialize(
self.library_id = library.id
if self.collection_ids is None:
self.collection_ids = [
collection.id for collection in library.collection_ids
collection.id for collection in library.associated_collections_ids
]
self.display_name = display_name
if genres:
Expand Down
8 changes: 4 additions & 4 deletions src/palace/manager/sqlalchemy/model/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Library(Base, HasSessionCache):
uselist=False,
)

def collections_query(self, base_query: Select | None = None) -> Select:
def _associated_collections_query(self, base_query: Select | None = None) -> Select:
from palace.manager.sqlalchemy.model.collection import Collection
from palace.manager.sqlalchemy.model.integration import (
IntegrationConfiguration,
Expand All @@ -182,7 +182,7 @@ def collections_query(self, base_query: Select | None = None) -> Select:
)

@property
def collection_ids(self) -> list[CollectionInfoTuple]:
def associated_collections_ids(self) -> list[CollectionInfoTuple]:
"""Get the collection ids for this library"""
from palace.manager.sqlalchemy.model.collection import Collection
from palace.manager.sqlalchemy.model.integration import IntegrationConfiguration
Expand All @@ -191,15 +191,15 @@ def collection_ids(self) -> list[CollectionInfoTuple]:
query = select(Collection.id, IntegrationConfiguration.protocol).select_from(
Collection
)
query = self.collections_query(query)
query = self._associated_collections_query(query)
results = _db.execute(query).all()
return [CollectionInfoTuple(*row) for row in results]

@property
def associated_collections(self) -> Sequence[Collection]:
"""Get all associated collections for this library."""
_db = Session.object_session(self)
return _db.scalars(self.collections_query()).all()
return _db.scalars(self._associated_collections_query()).all()

# Cache of the libraries loaded settings object
_settings: LibrarySettings | None
Expand Down

0 comments on commit 15cafd5

Please sign in to comment.