search: log extra search metadata to NewRelic.
When a user does a tag search, log a few more things, including the normalized search string, the number of tags in the search string, and the number of results.
This commit is contained in:
@@ -12,6 +12,7 @@ class PostsController < ApplicationController
|
||||
tag_query = params[:tags] || params.dig(:post, :tags)
|
||||
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit], random: params[:random], format: params[:format])
|
||||
@posts = authorize @post_set.posts, policy_class: PostPolicy
|
||||
@post_set.log!
|
||||
respond_with(@posts) do |format|
|
||||
format.atom
|
||||
end
|
||||
|
||||
@@ -160,6 +160,24 @@ module PostSets
|
||||
end
|
||||
end
|
||||
|
||||
def search_stats
|
||||
{
|
||||
query: normalized_query.to_s,
|
||||
count: post_count,
|
||||
page: current_page,
|
||||
limit: per_page,
|
||||
term_count: normalized_query.terms.count,
|
||||
tag_count: normalized_query.tags.count,
|
||||
metatag_count: normalized_query.metatags.count,
|
||||
censored_posts: censored_posts.count,
|
||||
hidden_posts: hidden_posts.count,
|
||||
}
|
||||
end
|
||||
|
||||
def log!
|
||||
DanbooruLogger.add_attributes("search", search_stats)
|
||||
end
|
||||
|
||||
concerning :TagListMethods do
|
||||
def related_tags
|
||||
if query.is_wildcard_search?
|
||||
|
||||
Reference in New Issue
Block a user