Sha256: 4281a94183e93f21543905bad6e62476d03e1c019d423da531161121979a7239
Contents?: true
Size: 862 Bytes
Versions: 10
Compression:
Stored size: 862 Bytes
Contents
# Adds methods to enable tracking tags through a common polymorphic association module ActsAsTaggableOn class Tag def self.most_hit(since=nil, limit=5) query = Tagging.scoped. joins('INNER JOIN punches ON (taggings.taggable_id = punches.punchable_id AND taggings.taggable_type = punches.punchable_type)'). group(:tag_id). order('SUM(punches.hits) DESC'). limit(limit) query = query.where('punches.average_time >= ?', since) if since query.map(&:tag) end def hits(since=nil) query = Tagging.scoped. joins('INNER JOIN punches ON (taggings.taggable_id = punches.punchable_id AND taggings.taggable_type = punches.punchable_type)'). where(:tag_id => self.id) query = query.where('punches.average_time >= ?', since) if since query.sum('punches.hits') end end end
Version data entries
10 entries across 10 versions & 1 rubygems