Skip to content

Commit

Permalink
Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
GUI committed Mar 3, 2024
1 parent 10fb2ab commit f8f74a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/api-umbrella/web-app/actions/v0/analytics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ local function generate_organization_summary(start_time, end_time, recent_start_
search:set_interval("month")
search:filter_exclude_imported()
search:aggregate_by_interval_for_summary()
search:aggregate_by_cardinality("user_id.hash")
search:aggregate_by_cardinality("user_id", "user_id.hash")
search:aggregate_by_response_time_average()
if config["web"]["analytics_v0_summary_filter"] then
search:set_search_query_string(config["web"]["analytics_v0_summary_filter"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,18 +436,18 @@ function _M:aggregate_by_term(field, size)
}
end

function _M:aggregate_by_cardinality(field)
self.body["aggregations"]["unique_" .. field] = {
function _M:aggregate_by_cardinality(field_name, field)
self.body["aggregations"]["unique_" .. field_name] = {
cardinality = {
field = field,
field = field or field_name,
precision_threshold = 3000,
},
}
end

function _M:aggregate_by_users(size)
self:aggregate_by_term("user_email", size)
self:aggregate_by_cardinality("user_email.hash")
self:aggregate_by_cardinality("user_email", "user_email.hash")
end

function _M:aggregate_by_request_ip(size)
Expand Down
8 changes: 4 additions & 4 deletions test/proxy/logging/test_special_chars.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,12 @@ def test_invalid_quotes

record = wait_for_log(response)[:hit_source]
# CI returns a slightly different response than local dev for some reason.
if record["request_referer"].include?("\xC0\xA7")
assert_equal("{\"user_agent\": \"foo \xC0\xA7?? bar\"}", record["request_referer"])
assert_equal("{\"user_agent\": \"foo \xC0\xA7?? bar\"}", record["request_user_agent"])
else
if record["request_referer"].include?("foo ?? ")
assert_equal("{\"user_agent\": \"foo ?? bar\"}", record["request_referer"])
assert_equal("{\"user_agent\": \"foo ?? bar\"}", record["request_user_agent"])
else
assert_equal("{\"user_agent\": \"foo \xC0\xA7?? bar\"}", record["request_referer"])
assert_equal("{\"user_agent\": \"foo \xC0\xA7?? bar\"}", record["request_user_agent"])
end
end
end

0 comments on commit f8f74a3

Please sign in to comment.