Advertisement
Guest User

ahora si

a guest
Mar 4th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def matches_this_week(client)
  2. query = "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.id.to_s + " AND pl.id = " + id.to_s + " AND t.begin_datetime > '" + DateTime.now.beginning_of_week.strftime("%Y-%m-%d %H:%M:%S") + "' AND t.end_datetime < '" + DateTime.now.end_of_week.strftime("%Y-%m-%d %H:%M:%S") + "'"
  3. matches.find_by_sql(query).count
  4. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement