Class: ActiveAnalytics::BrowsersPerDay
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActiveAnalytics::BrowsersPerDay
- Defined in:
- app/models/active_analytics/browsers_per_day.rb
Class Method Summary collapse
- .append(params) ⇒ Object
- .filter_by(params) ⇒ Object
- .group_by_date ⇒ Object
- .group_by_name ⇒ Object
- .group_by_version ⇒ Object
Instance Method Summary collapse
Class Method Details
.append(params) ⇒ Object
9 10 11 12 13 |
# File 'app/models/active_analytics/browsers_per_day.rb', line 9 def self.append(params) total = params.delete(:total) || 1 params[:site] = params[:site].downcase if params[:site] where(params).first.try(:increment!, :total, total) || create!(params.merge(total: total)) end |
.filter_by(params) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/models/active_analytics/browsers_per_day.rb', line 27 def self.filter_by(params) scope = all scope = scope.between_dates(params[:from], params[:to]) if params[:from].present? && params[:to].present? scope = scope.where(site: params[:site]) if params[:site].present? scope = scope.where(name: params[:id]) if params[:id].present? scope = scope.where(version: params[:version]) if params[:version].present? scope end |
.group_by_date ⇒ Object
23 24 25 |
# File 'app/models/active_analytics/browsers_per_day.rb', line 23 def self.group_by_date group(:date).select("date, sum(total) as total") end |
.group_by_name ⇒ Object
15 16 17 |
# File 'app/models/active_analytics/browsers_per_day.rb', line 15 def self.group_by_name group(:name).select("name, sum(total) AS total") end |
.group_by_version ⇒ Object
19 20 21 |
# File 'app/models/active_analytics/browsers_per_day.rb', line 19 def self.group_by_version group(:name, :version).select("version, sum(total) AS total") end |
Instance Method Details
#to_param ⇒ Object
36 37 38 |
# File 'app/models/active_analytics/browsers_per_day.rb', line 36 def to_param name end |