Remove message cleanup from webapp

This commit is contained in:
Jeremy Zhang 2017-09-22 00:59:37 +00:00
parent c0798bd5b1
commit 1ac5ac3eeb
2 changed files with 1 additions and 13 deletions

View File

@ -435,17 +435,5 @@ def cleanup_keyval_db():
if canCleanupDB(): if canCleanupDB():
db.session.query(KeyValueProperties).filter(KeyValueProperties.expiration < datetime.datetime.now()).delete() db.session.query(KeyValueProperties).filter(KeyValueProperties.expiration < datetime.datetime.now()).delete()
db.session.commit() db.session.commit()
guilds = Guilds.query.all()
for guild in guilds:
try:
channelsjson = json.loads(guild.channels)
except:
continue
for channel in channelsjson:
chanid = channel["id"]
keep_these = db.session.query(Messages.id).filter(Messages.channel_id == chanid).order_by(Messages.timestamp.desc()).limit(50)
db.session.query(Messages).filter(Messages.channel_id == chanid, ~Messages.id.in_(keep_these)).delete(synchronize_session=False)
db.session.commit()
return ('', 204) return ('', 204)
abort(401) abort(401)

View File

@ -30,7 +30,7 @@
<div class="col s12"> <div class="col s12">
<div class="card-panel indigo lighten-5 z-depth-3 hoverable black-text"> <div class="card-panel indigo lighten-5 z-depth-3 hoverable black-text">
<h4>Run a Database Cleanup</h4> <h4>Run a Database Cleanup</h4>
<p class="flow-text">Clears the keyval caches and purges the old messages. (Hit once, and wait a minute)</p> <p class="flow-text">Clears the keyval caches. (Hit once, and wait a minute)</p>
<a class="waves-effect waves-light btn" id="db_cleanup_btn">Run DB Cleanup Task</a> <a class="waves-effect waves-light btn" id="db_cleanup_btn">Run DB Cleanup Task</a>
</div> </div>
</div> </div>