Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. def matches_this_week(client)
  2. matches.find_by_sql("SELECT * FROM matches m INNER JOIN participations p ON p.match_id = m.id INNER JOIN players pl ON p.player_id = pl.id INNER JOIN timeslots t ON t.match_id = m.id INNER JOIN courts c ON t.court_id = c.id INNER JOIN clients cl ON c.client_id = cl.id WHERE cl.id = :client AND pl.id = :player AND t.begin_datetime > :start AND t.end_datetime < :end", {:client => client.id, :player => id, :start => DateTime.now.beginning_of_week, :end => DateTime.now.end_of_week}).count
  3. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement