Last active
December 20, 2015 07:09
-
-
Save shamil614/6090840 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# find any jobs that chronologically overlap an array of job_assignments | |
# ex: find any jobs that overlap an interpreter's existing jobs via the job_assignments | |
def self.overlapping(job_assignments) | |
jobs_table = Job.arel_table | |
query = Job.scoped | |
job_assignments.each do |ja| | |
query = query.where((jobs_table[:start_datetime].in(ja.scheduled_start..ja.estimated_end)). | |
or(jobs_table[:end_datetime].in(ja.scheduled_start..ja.estimated_end))) | |
end | |
query | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment