Guest User

Untitled

a guest
Feb 19th, 2018
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. SELECT count(id) as hits,
  2. LEFT(created_at,10) as created_on,
  3. event_id FROM `visits` WHERE (left(created_at,10) = '2008-08-19' and type = 'EventVisit') AND ( (`visits`.`type` = 'EventVisit' ) ) GROUP BY created_on, event_id ORDER BY created_on DESC, event_id ASC
  4.  
  5. def self.report_for_day(day)
  6. find(:all,{
  7. :select => "count(id) as hits,
  8. LEFT(created_at,10) as created_on,
  9. event_id",
  10. :conditions => [ "left(created_at,10) = ? and type = ?", day, 'EventVisit'],
  11. :group => "created_on, event_id",
  12. :order => "created_on DESC, event_id ASC"
  13. })
  14. end
  15.  
  16.  
  17. Event.find(:all, :conditions => ["is_published = ? AND end_at > ?", true, (Time.now+30.days).to_s(:db) ] ) do |e|
  18.  
  19. if e.tz.utc_offset == offset * 60 * 60
  20. find(:all,{
  21. :select => "count(id) as hits,LEFT(created_at,10) as created_on,event_id",
  22. :conditions => [ "created_at between ? and ?, and type = ? and event_id = e.id ", e.tz.now.beginning_of_day.to_s(:db), e.tz.now.end_of_day .to_s(:db), day, 'EventVisit'],
  23. :group => "created_on", #???
  24. :order => "created_on DESC"
  25. })
  26. end
  27. end
  28. end
Add Comment
Please, Sign In to add comment