posts: fix search queries not being logged to NewRelic in some cases (#4900)

Fix the /posts index controller not logging the normalized search query
to NewRelic when the search failed, either because of a tag limit error,
a search timeout, or a RSS feed rate limit error.

Also don't log the number of search results when it's an API request or
failed search. This is to avoid doing a potentially slow full post count
when it's not otherwise needed.
This commit is contained in:
evazion
2022-01-11 13:22:24 -06:00
parent 698d732667
commit 1518c3c4be
5 changed files with 30 additions and 28 deletions

View File

@@ -458,7 +458,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
context "for a search that times out" do
context "during numbered pagination" do
should "show the search timeout error page" do
Post::const_get(:ActiveRecord_Relation).any_instance.stubs(:records).raises(ActiveRecord::QueryCanceled)
PostSets::Post.any_instance.stubs(:posts).raises(ActiveRecord::QueryCanceled)
get posts_path(page: "1")
assert_response 500
@@ -468,7 +468,7 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
context "during sequential pagination" do
should "show the search timeout error page" do
Post::const_get(:ActiveRecord_Relation).any_instance.stubs(:records).raises(ActiveRecord::QueryCanceled)
PostSets::Post.any_instance.stubs(:posts).raises(ActiveRecord::QueryCanceled)
get posts_path(page: "a0")
assert_response 500