Add fix incorrect play duration
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user