refine logic to cleanup old sessions
This commit is contained in:
parent
6ca148b515
commit
77268fd218
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue