mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 13:11:15 -07:00
Add ability to flush recently_added database table
This commit is contained in:
parent
9725c82187
commit
08c8ee0774
4 changed files with 56 additions and 21 deletions
4
API.md
4
API.md
|
@ -278,6 +278,10 @@ Returns:
|
|||
```
|
||||
|
||||
|
||||
### delete_recently_added
|
||||
Flush out all of the recently added items in the database.
|
||||
|
||||
|
||||
### delete_temp_sessions
|
||||
Flush out all of the temporary sessions in the database.
|
||||
|
||||
|
|
|
@ -998,6 +998,20 @@
|
|||
</div>
|
||||
<p class="help-block">Set the delay (in seconds) to wait for consecutive recently added items to group together and to allow metadata to be processed before sending the notification. Minimum 60 seconds.</p>
|
||||
</div>
|
||||
<div class="form-group advanced-setting">
|
||||
<label>Flush Recently Added</label>
|
||||
<p class="help-block">
|
||||
Attempt to fix recently added notifications by flushing out all of the recently added items in the database.<br />
|
||||
Warning: This will reset all recently added notifications. For emergency use only when recently added notifications are stuck!
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-form" type="button" id="delete_recently_added">Flush</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="notify_recently_added_upgrade" id="notify_recently_added_upgrade" value="1" ${config['notify_recently_added_upgrade']}> Send a Notification for New Versions <span class="settings-warning">[Not working]</span>
|
||||
|
@ -2156,11 +2170,17 @@ $(document).ready(function() {
|
|||
});
|
||||
|
||||
$("#delete_temp_sessions").click(function () {
|
||||
var msg = 'Are you sure you want to flush the temporary sessions?<br /><strong>This will reset all currently active sessions.</strong>';
|
||||
var msg = 'Are you sure you want to flush the temporary sessions?<br /><br /><strong>This will reset all currently active sessions.</strong>';
|
||||
var url = 'delete_temp_sessions';
|
||||
confirmAjaxCall(url, msg);
|
||||
});
|
||||
|
||||
$("#delete_recently_added").click(function () {
|
||||
var msg = 'Are you sure you want to flush the recently added items?<br /><br /><strong>This will reset all recently added notifications.</strong>';
|
||||
var url = 'delete_recently_added';
|
||||
confirmAjaxCall(url, msg);
|
||||
});
|
||||
|
||||
$("#switch_git_branch").click(function () {
|
||||
var current_remote = "${config['git_remote']}";
|
||||
var current_branch = "${config['git_branch']}";
|
||||
|
|
|
@ -38,31 +38,28 @@ def integrity_check():
|
|||
return result
|
||||
|
||||
|
||||
def drop_session_db():
|
||||
monitor_db = MonitorDatabase()
|
||||
monitor_db.action('DROP TABLE sessions')
|
||||
def clear_table(table=None):
|
||||
if table:
|
||||
monitor_db = MonitorDatabase()
|
||||
|
||||
|
||||
def clear_history_tables():
|
||||
logger.debug("Tautulli Database :: Deleting all session_history records... No turning back now bub.")
|
||||
monitor_db = MonitorDatabase()
|
||||
monitor_db.action('DELETE FROM session_history')
|
||||
monitor_db.action('DELETE FROM session_history_media_info')
|
||||
monitor_db.action('DELETE FROM session_history_metadata')
|
||||
monitor_db.action('VACUUM')
|
||||
logger.debug("Tautulli Database :: Clearing database table '%s'." % table)
|
||||
try:
|
||||
monitor_db.action('DELETE FROM %s' % table)
|
||||
monitor_db.action('VACUUM')
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error("Tautulli Database :: Failed to clear database table '%s': %s." % (table, e))
|
||||
return False
|
||||
|
||||
|
||||
def delete_sessions():
|
||||
logger.debug("Tautulli Database :: Clearing temporary sessions from database.")
|
||||
monitor_db = MonitorDatabase()
|
||||
logger.info("Tautulli Database :: Clearing temporary sessions from database.")
|
||||
return clear_table('sessions')
|
||||
|
||||
try:
|
||||
monitor_db.action('DELETE FROM sessions')
|
||||
monitor_db.action('VACUUM')
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.warn("Tautulli Database :: Unable to clear temporary sessions from database: %s." % e)
|
||||
return False
|
||||
|
||||
def delete_recently_added():
|
||||
logger.info("Tautulli Database :: Clearing recently added items from database.")
|
||||
return clear_table('recently_added')
|
||||
|
||||
|
||||
def db_filename(filename=FILENAME):
|
||||
|
|
|
@ -352,6 +352,20 @@ class WebInterface(object):
|
|||
else:
|
||||
return {'result': 'error', 'message': 'Flush sessions failed.'}
|
||||
|
||||
@cherrypy.expose
|
||||
@cherrypy.tools.json_out()
|
||||
@requireAuth(member_of("admin"))
|
||||
@addtoapi()
|
||||
def delete_recently_added(self, **kwargs):
|
||||
""" Flush out all of the recently added items in the database."""
|
||||
|
||||
result = database.delete_recently_added()
|
||||
|
||||
if result:
|
||||
return {'result': 'success', 'message': 'Recently added flushed.'}
|
||||
else:
|
||||
return {'result': 'error', 'message': 'Flush recently added failed.'}
|
||||
|
||||
|
||||
##### Libraries #####
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue