mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
fix: /playlists returning wrong playlists
+ homepage recently played showing wrong user id items on first run
This commit is contained in:
+6
-2
@@ -345,8 +345,12 @@ class PlaylistTable(Base):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_all(cls):
|
def get_all(cls, current_user: bool = True):
|
||||||
result = cls.all()
|
if current_user:
|
||||||
|
result = cls.execute(select(cls).where(cls.userid == get_current_userid()))
|
||||||
|
else:
|
||||||
|
result = cls.execute(select(cls))
|
||||||
|
|
||||||
return playlists_to_dataclasses(result)
|
return playlists_to_dataclasses(result)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ def get_recently_played(
|
|||||||
entries = _entries
|
entries = _entries
|
||||||
limit = 1
|
limit = 1
|
||||||
else:
|
else:
|
||||||
entries = ScrobbleTable.get_all(0, BATCH_SIZE)
|
entries = ScrobbleTable.get_all(0, BATCH_SIZE, userid=userid)
|
||||||
|
|
||||||
max_iterations = 20
|
max_iterations = 20
|
||||||
iterations = 0
|
iterations = 0
|
||||||
|
|||||||
@@ -201,6 +201,8 @@ class MixesPlugin(Plugin):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# FIXME: Make sure that different artists don't generate the same mix
|
||||||
|
|
||||||
for i, period in enumerate(artists.values()):
|
for i, period in enumerate(artists.values()):
|
||||||
# if previous period has less than its max
|
# if previous period has less than its max
|
||||||
# add the difference to this period's limit
|
# add the difference to this period's limit
|
||||||
@@ -226,6 +228,7 @@ class MixesPlugin(Plugin):
|
|||||||
period["created"] += 1
|
period["created"] += 1
|
||||||
|
|
||||||
print(f"⭐⭐⭐⭐ Created {len(mixes)} mixes")
|
print(f"⭐⭐⭐⭐ Created {len(mixes)} mixes")
|
||||||
|
print([m.title for m in mixes])
|
||||||
return mixes
|
return mixes
|
||||||
|
|
||||||
def get_mix_description(self, tracks: list[Track], artishash: str):
|
def get_mix_description(self, tracks: list[Track], artishash: str):
|
||||||
|
|||||||
Reference in New Issue
Block a user