Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- named_scope :between, lambda {|starting, ending|
- conditions = ['']
- conditions[0] += '(started_at > ? AND started_at < ?)'
- conditions << starting
- conditions << ending
- conditions[0] += ' OR (completed_at IS NULL AND stopped_at IS NULL AND end_at > ? AND end_at < ?)'
- conditions << starting
- conditions << ending
- conditions[0] += ' OR (completed_at IS NOT NULL AND completed_at > ? AND completed_at < ?)'
- conditions << starting
- conditions << ending
- conditions[0] += ' OR (stopped_at IS NOT NULL AND stopped_at > ? AND stopped_at < ?)'
- conditions << starting
- conditions << ending
- {:conditions => conditions}
- }
Add Comment
Please, Sign In to add comment