add new favorites to stats

This commit is contained in:
cwilvx
2024-10-14 17:23:29 +03:00
parent c1d7c73649
commit 99f9bc80c9
4 changed files with 68 additions and 21 deletions
+16
View File
@@ -8,6 +8,7 @@ from sqlalchemy import (
String,
and_,
delete,
func,
insert,
select,
update,
@@ -248,6 +249,21 @@ class FavoritesTable(Base):
result, total = cls.get_all_of_type("artist", start, limit)
return favorites_to_dataclass(result), total
@classmethod
def count_favs_in_period(cls, start_time: int, end_time: int):
result = cls.execute(
select(func.count(cls.id)).where(
and_(cls.timestamp >= start_time, cls.timestamp <= end_time)
)
)
result = result.fetchone()
if result:
return result[0]
return 0
class ScrobbleTable(Base):
__tablename__ = "scrobble"