27 lines
641 B
Ruby
27 lines
641 B
Ruby
# class Tag < ProtoTag
|
|
# belongs_to :module_app
|
|
|
|
# end
|
|
|
|
class Tag
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
include Impressionist::Impressionable
|
|
|
|
is_impressionable #:counter_cache => { :column_name => :view_count }
|
|
|
|
field :name, localize: true
|
|
field :view_count, :type => Integer, :default => 0
|
|
field :cloud_view_count, :type => Integer, :default => 0
|
|
|
|
belongs_to :module_tag, polymorphic: true
|
|
has_many :taggings, dependent: :destroy
|
|
|
|
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
|
|
|
|
end
|