Sha256: 5624d0f5f7cd0bfa8234dffa4366fe655f3169eccf1df9a1d88e539ce8c47ca8

Contents?: true

Size: 547 Bytes

Versions: 3

Compression:

Stored size: 547 Bytes

Contents

module Spree::Report::QueryTimeScale
  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

  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
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
spree_admin_insights-3.2.0 app/reports/spree/report/query_time_scale.rb
solidus_admin_insights-2.1.1 app/reports/spree/report/query_time_scale.rb
solidus_admin_insights-2.1.0 app/reports/spree/report/query_time_scale.rb