View difference between Paste ID: P4RjN6xM and YApCSH1K
SHOW: | | - or go back to the newest paste.
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 + " AND pl.id = " + id + " 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") + "'"
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