mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Refactor database delete_session_history_rows ids
This commit is contained in:
parent
38f64c7d85
commit
c979e78802
3 changed files with 25 additions and 22 deletions
|
@ -21,6 +21,7 @@ import threading
|
|||
import time
|
||||
|
||||
import plexpy
|
||||
import helpers
|
||||
import logger
|
||||
|
||||
FILENAME = "tautulli.db"
|
||||
|
@ -57,6 +58,24 @@ def delete_recently_added():
|
|||
return clear_table('recently_added')
|
||||
|
||||
|
||||
def delete_session_history_rows(row_ids=None):
|
||||
if row_ids:
|
||||
for table in ('session_history', 'session_history_media_info', 'session_history_metadata'):
|
||||
delete_rows_from_table(table=table, row_ids=row_ids)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def delete_rows_from_table(table, row_ids):
|
||||
if row_ids and isinstance(row_ids, basestring):
|
||||
row_ids = map(helpers.cast_to_int, row_ids.split(','))
|
||||
|
||||
logger.info(u"Tautulli Database :: Deleting row ids %s from %s database table", row_ids, table)
|
||||
query = "DELETE FROM " + table + " WHERE id IN (%s) " % ','.join(['?'] * len(row_ids))
|
||||
monitor_db = MonitorDatabase()
|
||||
monitor_db.action(query, row_ids)
|
||||
|
||||
|
||||
def db_filename(filename=FILENAME):
|
||||
""" Returns the filepath to the db """
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue