refine logic to cleanup old sessions

This commit is contained in:
Seth Call 2017-10-16 15:36:27 -05:00
parent 6ca148b515
commit 77268fd218
1 changed files with 1 additions and 4 deletions

View File

@ -902,12 +902,9 @@ module JamRuby
def self.cleanup_old_sessions
old_scheduled_start = "(create_type is NOT NULL AND music_sessions.scheduled_start < NOW() - '24 hour'::INTERVAL)"
# let session be restarted for up to 2 hours after finishing
session_not_finished = "(create_type IS NOT NULL AND music_sessions.session_removed_at < NOW() - '24 hour'::INTERVAL)"
old_adhoc_sessions = "(create_type IS NULL and music_sessions.created_at < NOW() - '24 hour'::INTERVAL)"
MusicSession.where("#{old_scheduled_start} OR #{session_not_finished} OR #{old_adhoc_sessions}").update_all(old: true)
MusicSession.where("#{old_scheduled_start} OR #{session_not_finished} OR #{old_adhoc_sessions}").where(old:false).update_all(old: true)
end
def end_history