Fix issue of offset and delete

Sqlalchemy doesnt like it, idk y
attempt fix again
This commit is contained in:
Jeremy "EndenDragon" Zhang 2017-06-24 13:03:54 -07:00 committed by GitHub
parent 44af174287
commit fc7e74cbe3

View File

@ -478,7 +478,9 @@ def cleanup_keyval_db():
continue
for channel in channelsjson:
chanid = channel["id"]
db.session.query(Messages).filter(Messages.channel_id == chanid).order_by(Messages.timestamp.desc()).offset(50).delete()
msgs = db.session.query(Messages).filter(Messages.channel_id == chanid).order_by(Messages.timestamp.desc()).offset(50).all()
for msg in msgs:
db.session.delete(msg)
db.session.commit()
return ('', 204)