Sha256: 6a56fc9838f8de88b122eb359562945684dba7f49a09ce6a9f5aff006be746da

Contents?: true

Size: 862 Bytes

Versions: 49

Compression:

Stored size: 862 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.utc, '$lte' => ends_at.utc },
            '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

49 entries across 49 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.26 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.45 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.25 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.23 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.44 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.22 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.43 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.21 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.42 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.20 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.41 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.19 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.40 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.18 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.39 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.17 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.38 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.5.16 app/queries/workarea/reports/searches_without_results_over_time.rb
workarea-core-3.4.37 app/queries/workarea/reports/searches_without_results_over_time.rb