Created
August 1, 2011 17:05
-
-
Save courtenay/1118530 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sample stats recording code | |
base = "w:#{site_id}:#{word}" | |
# hits per year | |
REDIS.incr "#{base}:#{created_at.year}" | |
# hits per month | |
REDIS.incr "#{base}:#{created_at.month}-#{created_at.year}" | |
# hits per day | |
REDIS.incr "#{base}:#{created_at.day}-#{created_at.month}-#{created_at.year}" | |
# hits by hour-of-day this month | |
REDIS.incr "#{base}:#{created_at.hour}h#{created_at.month}-#{created_at.year}" | |
So then to get the list of words for this month there's very little aggregation: | |
REDIS.sort wordlist, { :by => "w:#{site_id}:*:#{end_date.month}-#{end_date.year}", :order => "DESC" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment