mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
port: recent items for homepage
This commit is contained in:
+11
-3
@@ -35,9 +35,13 @@ class Base(MasterBase, DeclarativeBase):
|
||||
if cls.__tablename__ == "track":
|
||||
stmt = select(TrackTable.trackhash).where(cls.last_mod < create_date)
|
||||
elif cls.__tablename__ == "album":
|
||||
stmt = select(AlbumTable.albumhash).where(cls.created_date < create_date)
|
||||
stmt = select(AlbumTable.albumhash).where(
|
||||
cls.created_date < create_date
|
||||
)
|
||||
elif cls.__tablename__ == "artist":
|
||||
stmt = select(ArtistTable.artisthash).where(cls.created_date < create_date)
|
||||
stmt = select(ArtistTable.artisthash).where(
|
||||
cls.created_date < create_date
|
||||
)
|
||||
|
||||
result = conn.execute(stmt)
|
||||
return {row[0] for row in result.fetchall()}
|
||||
@@ -206,6 +210,11 @@ class TrackTable(Base):
|
||||
|
||||
return tracks_to_dataclasses(result.fetchall())
|
||||
|
||||
@classmethod
|
||||
def get_recently_played(cls, limit: int):
|
||||
result = cls.execute(select(cls).order_by(cls.lastplayed.desc()).limit(limit))
|
||||
return tracks_to_dataclasses(result.fetchall())
|
||||
|
||||
@classmethod
|
||||
def remove_tracks_by_filepaths(cls, filepaths: set[str]):
|
||||
with DbManager(commit=True) as conn:
|
||||
@@ -250,7 +259,6 @@ class AlbumTable(Base):
|
||||
all = result.fetchall()
|
||||
return albums_to_dataclasses(all)
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_album_by_albumhash(cls, hash: str):
|
||||
with DbManager() as conn:
|
||||
|
||||
Reference in New Issue
Block a user