CyberCraftInc / vacation_system

Cyber Craft Vacation System
0 stars 0 forks source link

Refactor vacations intersections finding logic #48

Open eleidan opened 8 years ago

eleidan commented 8 years ago

The VacationRequest#cannot_intersect_with_other_vacations can be implemented in more simple way, as follows:

(start_date - another.end_date) * (another.start_date - end_date) >= 0

But in SQL :wink:

josephbuchma commented 8 years ago

In postgres you can do it like this: ... where daterange(DATE '<user1_start_date>', DATE '<user1_end_date>') && daterange(DATE '<user2_start_date>', DATE '<user2_end_date>')