Sha256: 3590e8636ee0406cf472201206ee1ee6011574405445e95f3f24e48ceadfaa53

Contents?: true

Size: 641 Bytes

Versions: 8

Compression:

Stored size: 641 Bytes

Contents

module ReportsKit
  module Reports
    module Adapters
      class Postgresql
        def self.truncate_to_day(column)
          "#{column}::date"
        end

        def self.truncate_to_week(column)
          case ReportsKit.configuration.first_day_of_week
          when :sunday
            "DATE_TRUNC('week', #{column}::timestamp + '1 day'::interval) - '1 day'::interval"
          when :monday
            "DATE_TRUNC('week', #{column}::timestamp)"
          else
            raise ArgumentError.new("Unsupported first_day_of_week: #{ReportsKit.configuration.first_day_of_week}")
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
reports_kit-0.5.0 lib/reports_kit/reports/adapters/postgresql.rb
reports_kit-0.4.1 lib/reports_kit/reports/adapters/postgresql.rb
reports_kit-0.4.0 lib/reports_kit/reports/adapters/postgresql.rb
reports_kit-0.3.3 lib/reports_kit/reports/adapters/postgresql.rb
reports_kit-0.3.2 lib/reports_kit/reports/adapters/postgresql.rb
reports_kit-0.3.1 lib/reports_kit/reports/adapters/postgresql.rb
reports_kit-0.3.0 lib/reports_kit/reports/adapters/postgresql.rb
reports_kit-0.2.0 lib/reports_kit/reports/adapters/postgresql.rb