<% module_namespacing do -%> class <%= class_name %>Metric < ApplicationMetric
# ==> Change the default range (default is all) # default_range '24h' def scope <%= options[:scope] %> end def type <%= options[:type][0] == ':' ? options[:type] : ":#{options[:type]}" %> end <% if options[:group] %> def period <%= options[:group][0] == ':' ? options[:group] : ":#{options[:group]}" %> end <% else %> # ==> Change the grouping # def group # :color # end <% end %> # ==> Change the chart # def chart # :column_chart # end # ==> Register a new range # Add a range to the select # register_range '15w', label: "15 weeks" do # 15.weeks.ago # end # ==> Remove ranges # Remove ranges from the select # exclude_ranges '24h', '30d' # ==> Disable the form # Display the form if you have a metric that doesn't need to be queried (e.g. average user age of all users) # def form? # false # end # ==> Render chart async # Renders the chart asynchronously with an ajax request. There are some limitations. Read here. # def form? # false # end # ==> Change the collection label on ranges # def collection_label(range_thing) # "Born #{range_thing.label}" # end
end <% end -%>