Add button to clear notification logs

This commit is contained in:
JonnyWong16 2016-03-04 23:13:19 -08:00
commit 7f5d9bec87
3 changed files with 44 additions and 1 deletions

View file

@ -1206,4 +1206,16 @@ class DataFactory(object):
'draw': query['draw']
}
return dict
return dict
def delete_notification_log(self):
monitor_db = database.MonitorDatabase()
try:
logger.info(u"PlexPy DataFactory :: Clearing notification logs from database.")
monitor_db.action('DELETE FROM notify_log')
monitor_db.action('VACUUM')
return 'Cleared notification logs.'
except Exception as e:
logger.warn(u"PlexPy DataFactory :: Unable to execute database query for delete_notification_log: %s." % e)
return 'Unable to clear notification logs.'

View file

@ -1096,6 +1096,19 @@ class WebInterface(object):
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps(notifications)
@cherrypy.expose
@addtoapi()
def clearNotifyLogs(self, **kwargs):
data_factory = datafactory.DataFactory()
result = data_factory.delete_notification_log()
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'})
@cherrypy.expose
def clearLogs(self):
plexpy.LOG_LIST = []