Sha256: fc9ad2e8d0f550f165b4dcf304a6e526438e1ba686c82115c2484e2f2d795f23

Contents?: true

Size: 854 Bytes

Versions: 13

Compression:

Stored size: 854 Bytes

Contents

module Workarea
  module Reports
    class SearchesWithoutResultsOverTime
      include Report
      include GroupByTime

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

      def aggregation
        [filter, project_used_fields, group_by_time]
      end

      def filter
        {
          '$match' => {
            'reporting_on' => { '$gte' => starts_at, '$lte' => ends_at },
            'total_results' => 0
          }
        }
      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

13 entries across 13 versions & 1 rubygems

Version Path
workarea-core-3.4.22 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.0 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.21 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.0.beta.1 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.20 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.19 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.18 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.17 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.16 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.15 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.14 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.13 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.12 app/queries/workarea/reports/searches_without_results_over_time.rb