Sha256: 57dabe5cbe5e520bf777167895923879a11f7e4a37cbf13d33c8fce9c07733dd
Contents?: true
Size: 866 Bytes
Versions: 8
Compression:
Stored size: 866 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
8 entries across 8 versions & 1 rubygems