Link: https://github.com/ricodigo/shapado/blob/master/app/models/views_count.rb
Source:
class ViewsCount
include Mongoid::Document
include Mongoid::Timestamps
identity :type => String
def self.cleanup!
ViewsCount.delete_all(:created_at.lt => 8.days.ago)
end
end
A Ruby class representing a MongoDB document. Each instance stands for a view of a question page from a particular IP address. The id is composed of the id of the web page and the IP address of the viewer.
Contains a class method deleting all ViewsCount instances more than 8 days old.
No comments:
Post a Comment