Created
September 27, 2010 13:58
-
-
Save darkofabijan/599067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Longtail | |
attr_accessor :model | |
attr_accessor :field | |
def initialize(options) | |
@model = options[:model] | |
@field = options[:field] | |
end | |
def fetch | |
data = @model.count(:group => @field, :order => "count_all DESC") | |
data.to_a.collect { |set| [set.second] }.to_json | |
end | |
end | |
class AnalyticsBase | |
attr_accessor :longtail_graphs | |
def initialize | |
@longtail_graphs = [] | |
end | |
def register_longtail_graph(options) | |
@longtail_graphs << Longtail.new(options) | |
end | |
end | |
class Analytics < AnalyticsBase | |
register_longtail_graph :model => Design, :field => 'label_id' | |
register_longtail_graph :model => HeartVote, :field => 'user_id' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment