From 2c1ac0f12de9d8ce29956474379f3b337d1f935c Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Thu, 16 May 2024 17:09:36 +0200 Subject: [PATCH] fix: wrong collection --- music_kraken/objects/collection.py | 2 ++ music_kraken/objects/song.py | 15 ++++++++------- music_kraken/utils/shared.py | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/music_kraken/objects/collection.py b/music_kraken/objects/collection.py index d0cd75d..476ab3c 100644 --- a/music_kraken/objects/collection.py +++ b/music_kraken/objects/collection.py @@ -115,6 +115,7 @@ class Collection(Generic[T]): self._data.append(other) other._inner._is_in_collection.add(self) + """ for attribute, a in self.sync_on_append.items(): # syncing two collections by reference b = other.__getattribute__(attribute) @@ -133,6 +134,7 @@ class Collection(Generic[T]): a._collection_for[synced_with] = key a.extend(b_data, **kwargs) + """ # all of the existing hooks to get the defined datastructures for collection_attribute, generator in self.extend_object_to_attribute.items(): diff --git a/music_kraken/objects/song.py b/music_kraken/objects/song.py index 12749c9..9e95604 100644 --- a/music_kraken/objects/song.py +++ b/music_kraken/objects/song.py @@ -148,7 +148,7 @@ class Song(Base): self.feature_artist_collection.push_to = [self.artist_collection] self.artist_collection.pull_from = [self.feature_artist_collection] - self.album_collection.sync_on_append = { + self.album_collection.extend_object_to_attribute = { "artist_collection": self.artist_collection, } @@ -159,10 +159,6 @@ class Song(Base): "album_collection": self.album_collection } - self.album_collection.append_object_to_attribute = { - "artist_collection": self - } - def _add_other_db_objects(self, object_type: Type[OuterProxy], object_list: List[OuterProxy]): if object_type is Song: return @@ -223,7 +219,7 @@ class Song(Base): r = OPTION_FOREGROUND.value + self.title_string + BColors.ENDC.value + OPTION_BACKGROUND.value r += get_collection_string(self.album_collection, " from {}", ignore_titles={self.title}) r += get_collection_string(self.artist_collection, " by {}") - r += get_collection_string(self.feature_artist_collection, " feat. {}") + r += get_collection_string(self.feature_artist_collection, " feat. {}" if len(self.artist_collection) > 0 else " by {}") return r @property @@ -311,7 +307,7 @@ class Album(Base): self.song_collection.append_object_to_attribute = { "album_collection": self } - self.song_collection.sync_on_append = { + self.song_collection.extend_object_to_attribute = { "artist_collection": self.artist_collection } @@ -372,6 +368,7 @@ class Album(Base): def option_string(self) -> str: r = OPTION_FOREGROUND.value + self.title_string + BColors.ENDC.value + OPTION_BACKGROUND.value r += get_collection_string(self.artist_collection, " by {}") + r += get_collection_string(self.feature_artist_collection, " feat. {}" if len(self.artist_collection) > 0 else " by {}") r += get_collection_string(self.label_collection, " under {}") if len(self.song_collection) > 0: @@ -526,6 +523,10 @@ class Artist(Base): UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection",) def __init_collections__(self): + self.album_collection.append_object_to_attribute = { + "feature_artist_collection": self + } + self.label_collection.append_object_to_attribute = { "current_artist_collection": self } diff --git a/music_kraken/utils/shared.py b/music_kraken/utils/shared.py index 5f87876..2a5d4a4 100644 --- a/music_kraken/utils/shared.py +++ b/music_kraken/utils/shared.py @@ -12,10 +12,10 @@ if not load_dotenv(Path(__file__).parent.parent.parent / ".env"): __stage__ = os.getenv("STAGE", "prod") -DEBUG = (__stage__ == "dev") and False +DEBUG = (__stage__ == "dev") and True DEBUG_LOGGING = DEBUG and False DEBUG_TRACE = DEBUG and True -DEBUG_OBJECT_TRACE = DEBUG and False +DEBUG_OBJECT_TRACE = DEBUG and True DEBUG_OBJECT_TRACE_CALLSTACK = DEBUG_OBJECT_TRACE and False DEBUG_YOUTUBE_INITIALIZING = DEBUG and False DEBUG_PAGES = DEBUG and False