Sha256: bd2e828494ce684c44cee49e0445c20113f020a1257fbfbdb3105a44a959f578

Contents?: true

Size: 836 Bytes

Versions: 49

Compression:

Stored size: 836 Bytes

Contents

module Workarea
  module Reports
    class SearchesOverTime
      include Report
      include GroupByTime

      self.reporting_class = Metrics::SearchByDay
      self.sort_fields = %w(_id searches)

      def aggregation
        [filter_date_range, project_used_fields, group_by_time]
      end

      def filter_date_range
        {
          '$match' => {
            'reporting_on' => { '$gte' => starts_at.utc, '$lte' => ends_at.utc }
          }
        }
      end

      def project_used_fields
        { '$project' => { 'reporting_on' => 1, 'searches' => 1 } }
      end

      def group_by_time
        {
          '$group' => {
            '_id' => time_group_id,
            'starts_at' => { '$min' => '$reporting_on' },
            'searches' => { '$sum' => '$searches' }
          }
        }
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
workarea-core-3.5.15 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.4.36 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.5.14 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.4.35 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.5.13 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.4.34 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.5.12 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.4.33 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.5.11 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.5.10 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.4.32 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.5.9 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.4.31 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.5.8 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.4.30 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.5.7 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.4.29 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.5.6 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.4.28 app/queries/workarea/reports/searches_over_time.rb
workarea-core-3.5.5 app/queries/workarea/reports/searches_over_time.rb