I have a clicks table which logs clicks on links on the site.
In the links table I want a field weekly_clicks that would update via a cron job.
How can I write the following pseudocode query in Ruby/ActiveRecord?
Select count(clicks) FROM clicks
WHERE link_id=xxx
AND created_at within previous 7 days including today
1 Answer