mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
Add ability to clear the temporary sessions table from database
This commit is contained in:
parent
2ba529f9e3
commit
5c5722714d
2 changed files with 25 additions and 1 deletions
|
@ -38,9 +38,21 @@ def clear_history_tables():
|
||||||
monitor_db.action('DELETE FROM session_history')
|
monitor_db.action('DELETE FROM session_history')
|
||||||
monitor_db.action('DELETE FROM session_history_media_info')
|
monitor_db.action('DELETE FROM session_history_media_info')
|
||||||
monitor_db.action('DELETE FROM session_history_metadata')
|
monitor_db.action('DELETE FROM session_history_metadata')
|
||||||
monitor_db.action('VACUUM;')
|
monitor_db.action('VACUUM')
|
||||||
|
|
||||||
|
|
||||||
|
def delete_sessions():
|
||||||
|
logger.debug(u"PlexPy Database :: Clearing temporary sessions from database.")
|
||||||
|
monitor_db = MonitorDatabase()
|
||||||
|
|
||||||
|
try:
|
||||||
|
monitor_db.action('DELETE FROM sessions')
|
||||||
|
monitor_db.action('VACUUM')
|
||||||
|
return 'Cleared temporary sessions.'
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn(u"PlexPy Database :: Unable to clear temporary sessions from database: %s." % e)
|
||||||
|
return 'Unable to clear temporary sessions.'
|
||||||
|
|
||||||
def db_filename(filename="plexpy.db"):
|
def db_filename(filename="plexpy.db"):
|
||||||
""" Returns the filepath to the db """
|
""" Returns the filepath to the db """
|
||||||
|
|
||||||
|
|
|
@ -254,6 +254,18 @@ class WebInterface(object):
|
||||||
logger.warn(u"Unable to retrieve data for get_recently_added.")
|
logger.warn(u"Unable to retrieve data for get_recently_added.")
|
||||||
return serve_template(templatename="recently_added.html", data=None)
|
return serve_template(templatename="recently_added.html", data=None)
|
||||||
|
|
||||||
|
@cherrypy.expose
|
||||||
|
def delete_temp_sessions(self):
|
||||||
|
|
||||||
|
result = database.delete_sessions()
|
||||||
|
|
||||||
|
if result:
|
||||||
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
return json.dumps({'message': result})
|
||||||
|
else:
|
||||||
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
return json.dumps({'message': 'no data received'})
|
||||||
|
|
||||||
|
|
||||||
##### Libraries #####
|
##### Libraries #####
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue