Last active
November 28, 2015 04:19
-
-
Save nicooga/4793fa88d9f94cbf7d7a 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
Professor.available_at_or_around_or_partially start_time: Time.now, end_time: Time.now.+(2.hours) | |
SELECT "professors".* | |
INNER JOIN "professor_availability_periods" | |
ON "professor_availability_periods"."professor_id" = "professors"."id" | |
WHERE | |
( | |
( | |
/* available_at */ | |
("professor_availability_periods"."starts_at_sfsow" <= 446340) | |
AND ("professor_availability_periods"."ends_at_sfsow" >= 453540) | |
/* available_around */ | |
OR ( | |
("professor_availability_periods"."starts_at_sfsow" <= 442740) | |
AND ("professor_availability_periods"."ends_at_sfsow" >= 446340) | |
OR | |
("professor_availability_periods"."starts_at_sfsow" <= 453540) | |
AND ("professor_availability_periods"."ends_at_sfsow" >= 457140) | |
) | |
) | |
/* partially_available_at */ | |
OR ("professor_availability_periods"."starts_at_sfsow" >= 446340) | |
AND ("professor_availability_periods"."ends_at_sfsow" <= 453540) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment