Add fix incorrect play duration

This commit is contained in:
2024-06-26 12:11:09 +08:00
parent bc34a4f839
commit b2ea5ddd8d
3 changed files with 55 additions and 4 deletions

View File

@@ -21,7 +21,8 @@ class PlaybackReportingDb:
def get_activitys(self, offset: int = 0, limit: int = 100,
itemType: str = None, userId: str = None,
startTime: float = None, endTime: float = None):
startTime: float = None, endTime: float = None,
clientName: str = None, deviceName: str = None):
where_sqls = []
where_sql = ''
args = []
@@ -37,6 +38,12 @@ class PlaybackReportingDb:
if endTime is not None:
where_sqls.append('DateCreated <= ?')
args.append(format_time(endTime))
if clientName is not None:
where_sqls.append("ClientName = ?")
args.append(clientName)
if deviceName is not None:
where_sqls.append("DeviceName = ?")
args.append(deviceName)
if len(where_sqls):
where_sql = ' WHERE ' + " AND ".join(where_sqls)
args.append(limit)
@@ -45,6 +52,11 @@ class PlaybackReportingDb:
cur.row_factory = sqlite3.Row
return [dict(i) for i in cur.fetchall()]
def get_client_devices(self):
cur = self._db.execute("SELECT ClientName, DeviceName FROM PlaybackActivity GROUP BY ClientName, DeviceName;") # noqa: E501
cur.row_factory = sqlite3.Row
return [dict(i) for i in cur.fetchall()]
def get_users(self, itemType: str = None):
where_sql = ''
args = []
@@ -55,6 +67,9 @@ class PlaybackReportingDb:
cur.row_factory = sqlite3.Row
return [dict(i) for i in cur.fetchall()]
def update_playduration(self, rowid: int, duration: int):
self._db.execute("UPDATE PlaybackActivity SET PlayDuration = ? WHERE rowid = ?;", [duration, rowid]) # noqa: E501
class LibraryDb:
def __init__(self, fn: str):