Sha256: c2e81614daa5877625fa90f396609ee80280503e8075fe796facc0e462c9c49d
Contents?: true
Size: 944 Bytes
Versions: 1
Compression:
Stored size: 944 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, options = {}) 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 if options[:fill_limit] && query.length < limit end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
punching_bag-0.5.0 | lib/punching_bag/acts_as_taggable_on.rb |