2012-12-28 02:43:48 +00:00
|
|
|
# class Tag < ProtoTag
|
|
|
|
# belongs_to :module_app
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
class Tag
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
include Impressionist::Impressionable
|
|
|
|
|
2013-07-19 08:59:08 +00:00
|
|
|
is_impressionable #:counter_cache => { :column_name => :view_count }
|
2012-12-28 02:43:48 +00:00
|
|
|
|
2013-04-26 03:18:57 +00:00
|
|
|
field :name, localize: true
|
2012-12-28 02:43:48 +00:00
|
|
|
field :view_count, :type => Integer, :default => 0
|
2013-01-08 04:36:50 +00:00
|
|
|
field :cloud_view_count, :type => Integer, :default => 0
|
|
|
|
|
2013-04-26 03:18:57 +00:00
|
|
|
belongs_to :module_tag, polymorphic: true
|
|
|
|
has_many :taggings, dependent: :destroy
|
|
|
|
|
2012-12-28 02:43:48 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
def self.get_impressionist(item_tag = self)
|
|
|
|
item_tag.impressions.where(:created_at.gte=> 14.days.ago,:created_at.lte => Time.now).count
|
|
|
|
end
|
2012-07-31 03:57:32 +00:00
|
|
|
|
2012-02-14 16:32:20 +00:00
|
|
|
end
|