-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#160332453] modify DateRangeTopNFieldQuery to allow queries without …
…an affiliate (#146) - refactor some logstash query code
- Loading branch information
1 parent
cc927cc
commit 0368ee4
Showing
6 changed files
with
45 additions
and
23 deletions.
There are no files selected for viewing
15 changes: 10 additions & 5 deletions
15
app/models/logstash_queries/date_range_top_n_field_query.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
class DateRangeTopNFieldQuery < DateRangeTopNQuery | ||
attr_reader :filters | ||
|
||
def initialize(affiliate_name, start_date, end_date, filter_field, filter_value, agg_options = {}) | ||
super(affiliate_name, start_date, end_date, agg_options) | ||
@filter_field, @filter_value = filter_field, filter_value | ||
@filters = { 'affiliate' => @affiliate_name, filter_field => filter_value }.compact | ||
end | ||
|
||
def booleans(json) | ||
filters.each do |field, value| | ||
json.must do | ||
json.child! { json.term { json.set! field, value } } | ||
end | ||
end | ||
|
||
json.must do | ||
json.child! { json.term { json.affiliate @affiliate_name } } | ||
json.child! { json.term { json.set! @filter_field, @filter_value } } | ||
json.child! { date_range(json, @start_date, @end_date) } | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters