-
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.
SRCH-1305 update analytics queries to query by
type
field (#566)
- Loading branch information
1 parent
28764c1
commit 706419d
Showing
89 changed files
with
510 additions
and
201 deletions.
There are no files selected for viewing
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 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 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 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
21 changes: 10 additions & 11 deletions
21
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,21 +1,20 @@ | ||
class DateRangeTopNFieldQuery < DateRangeTopNQuery | ||
attr_reader :filters | ||
attr_reader :filter_field, :filter_value | ||
|
||
def initialize(affiliate_name, start_date, end_date, filter_field, filter_value, agg_options = {}) | ||
super(affiliate_name, start_date, end_date, agg_options) | ||
@filters = { 'params.affiliate' => @affiliate_name, | ||
filter_field => filter_value }.compact | ||
def initialize(affiliate_name, type, start_date, end_date, filter_field, filter_value, agg_options = {}) | ||
super(affiliate_name, type, start_date, end_date, agg_options) | ||
@filter_field = filter_field | ||
@filter_value = filter_value | ||
end | ||
|
||
def booleans(json) | ||
filters.each do |field, value| | ||
json.filter do | ||
json.child! { json.term { json.set! field, value } } | ||
end | ||
end | ||
must_affiliate(json, affiliate_name) if affiliate_name | ||
must_type(json, type) | ||
|
||
json.filter do | ||
json.child! { date_range(json, @start_date, @end_date) } | ||
json.child! { json.term { json.set! filter_field, filter_value } } | ||
end | ||
|
||
must_date_range(json, start_date, end_date) | ||
end | ||
end |
7 changes: 4 additions & 3 deletions
7
app/models/logstash_queries/date_range_top_n_missing_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
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,13 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
class DateRangeTopNQuery < TopNQuery | ||
attr_reader :start_date, :end_date | ||
|
||
def initialize(affiliate_name, start_date, end_date, agg_options = {}) | ||
super(affiliate_name, agg_options) | ||
@start_date, @end_date = start_date, end_date | ||
def initialize(affiliate_name, type, start_date, end_date, agg_options = {}) | ||
super(affiliate_name, type, agg_options) | ||
@start_date = start_date | ||
@end_date = end_date | ||
end | ||
|
||
def booleans(json) | ||
must_affiliate_date_range(json, @affiliate_name, @start_date, @end_date) | ||
must_affiliate(json, affiliate_name) | ||
must_type(json, type) | ||
must_date_range(json, start_date, end_date) | ||
must_not_spider(json) | ||
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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,8 @@ def aggs_field | |
def top_clicks | ||
most_popular | ||
end | ||
|
||
def type | ||
'click' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
class RtuCount | ||
# frozen_string_literal: true | ||
|
||
def self.count(index, type, query_body) | ||
ES::ELK.client_reader.count(index: index, type: type, body: query_body)["count"] rescue nil | ||
class RtuCount | ||
def self.count(index, query_body) | ||
ES::ELK.client_reader.count(index: index, body: query_body)['count'] | ||
rescue StandardError => error | ||
Rails.logger.error("Error extracting RtuCount: #{error}") | ||
nil | ||
end | ||
|
||
end |
Oops, something went wrong.