Module: Spree::Report::QueryTimeScale

Defined in:
app/reports/spree/report/query_time_scale.rb

Class Method Summary collapse

Class Method Details

.select(time_scale, time_scale_on) ⇒ Object



2
3
4
5
# File 'app/reports/spree/report/query_time_scale.rb', line 2

def self.select(time_scale, time_scale_on)
  db_col_name = time_scale_on.present? ? "#{ time_scale_on }.created_at" : "created_at"
  time_scale_columns(time_scale).collect { |time_scale_column| ::Spree::Report::QueryFragments.public_send(time_scale_column, db_col_name) }
end

.time_scale_columns(time_scale) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/reports/spree/report/query_time_scale.rb', line 7

def self.time_scale_columns(time_scale)
  case time_scale
  when :hourly
    [:day, :hour]
  when :daily
    [:month, :day]
  when :monthly
    [:year, :month]
  when :yearly
    [:year]
  end
end