Class: Workarea::Reports::SearchesOverTime
- Inherits:
-
Object
- Object
- Workarea::Reports::SearchesOverTime
show all
- Includes:
- GroupByTime, Report
- Defined in:
- app/queries/workarea/reports/searches_over_time.rb
Instance Method Summary
collapse
#group_by, #time_group_id
Methods included from Report
#cache_key, #count, #ends_at, #initialize, #limit, #more_results?, #results, #slug, #sort, #sort_by, #sort_direction, #sort_value, #starts_at
Instance Method Details
#aggregation ⇒ Object
10
11
12
|
# File 'app/queries/workarea/reports/searches_over_time.rb', line 10
def aggregation
[filter_date_range, project_used_fields, group_by_time]
end
|
#filter_date_range ⇒ Object
14
15
16
17
18
19
20
|
# File 'app/queries/workarea/reports/searches_over_time.rb', line 14
def filter_date_range
{
'$match' => {
'reporting_on' => { '$gte' => starts_at.utc, '$lte' => ends_at.utc }
}
}
end
|
#group_by_time ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'app/queries/workarea/reports/searches_over_time.rb', line 26
def group_by_time
{
'$group' => {
'_id' => time_group_id,
'starts_at' => { '$min' => '$reporting_on' },
'searches' => { '$sum' => '$searches' }
}
}
end
|
#project_used_fields ⇒ Object
22
23
24
|
# File 'app/queries/workarea/reports/searches_over_time.rb', line 22
def project_used_fields
{ '$project' => { 'reporting_on' => 1, 'searches' => 1 } }
end
|