From c1a1741d20bf60063ef43bde2d595e9f62c993cb Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 12 Jan 2022 10:25:35 -0600 Subject: [PATCH] posts: add `z=N` URL param to searches and tag lists. Add a `z=N` param to the URL when doing a search from the search box, or when clicking a link in the tag list. This is to gather data on how often the links in the tag list are used, and whether it's more common to click tags in the tag list or to perform searches manually. This is temporary and will be removed when enough data is collected. --- app/components/paginator_component.rb | 2 +- .../tag_list_component.html+categorized.erb | 12 ++++++------ .../tag_list_component.html+search.erb | 12 ++++++------ app/views/posts/partials/common/_search.html.erb | 1 + 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/components/paginator_component.rb b/app/components/paginator_component.rb index b82f654fb..697666391 100644 --- a/app/components/paginator_component.rb +++ b/app/components/paginator_component.rb @@ -41,6 +41,6 @@ class PaginatorComponent < ApplicationComponent end def url_for_page(page) - url_for(**params.merge(page: page).permit!) + url_for(**params.merge(page: page).except(:z).permit!) end end diff --git a/app/components/tag_list_component/tag_list_component.html+categorized.erb b/app/components/tag_list_component/tag_list_component.html+categorized.erb index a47aad530..57be84ed3 100644 --- a/app/components/tag_list_component/tag_list_component.html+categorized.erb +++ b/app/components/tag_list_component/tag_list_component.html+categorized.erb @@ -8,19 +8,19 @@ <% tags.each do |t| %>
  • <% if t.artist? %> - <%= link_to "?", show_or_new_artists_path(name: t.name), class: "wiki-link" %> + <%= link_to "?", show_or_new_artists_path(name: t.name, z: 1), class: "wiki-link" %> <% elsif t.name =~ /\A\d+\z/ %> - <%= link_to "?", wiki_page_path("~#{t.name}"), class: "wiki-link" %> + <%= link_to "?", wiki_page_path("~#{t.name}", z: 1), class: "wiki-link" %> <% else %> - <%= link_to "?", wiki_page_path(t.name), class: "wiki-link" %> + <%= link_to "?", wiki_page_path(t.name, z: 1), class: "wiki-link" %> <% end %> <% if show_extra_links && current_query.present? %> - <%= link_to "+", posts_path(tags: "#{current_query} #{t.name}"), class: "search-inc-tag" %> - <%= link_to "-", posts_path(tags: "#{current_query} -#{t.name}"), class: "search-exl-tag" %> + <%= link_to "+", posts_path(tags: "#{current_query} #{t.name}", z: 3), class: "search-inc-tag" %> + <%= link_to "-", posts_path(tags: "#{current_query} -#{t.name}", z: 3), class: "search-exl-tag" %> <% end %> - <%= link_to t.pretty_name, posts_path(tags: t.name), class: "search-tag" %> + <%= link_to t.pretty_name, posts_path(tags: t.name, z: 1), class: "search-tag" %> <%= tag.span humanized_number(t.post_count), class: ["post-count", ("low-post-count" if is_underused_tag?(t))], title: t.post_count %>
  • diff --git a/app/components/tag_list_component/tag_list_component.html+search.erb b/app/components/tag_list_component/tag_list_component.html+search.erb index 1f648db46..b92e18279 100644 --- a/app/components/tag_list_component/tag_list_component.html+search.erb +++ b/app/components/tag_list_component/tag_list_component.html+search.erb @@ -3,19 +3,19 @@
  • <%# ignore search:foo metatags %> <% if t.artist? %> - <%= link_to "?", show_or_new_artists_path(name: t.name), class: "wiki-link" %> + <%= link_to "?", show_or_new_artists_path(name: t.name, z: 2), class: "wiki-link" %> <% elsif t.name =~ /\A\d+\z/ %> - <%= link_to "?", wiki_page_path("~#{t.name}"), class: "wiki-link" %> + <%= link_to "?", wiki_page_path("~#{t.name}", z: 2), class: "wiki-link" %> <% else %> - <%= link_to "?", wiki_page_path(t.name), class: "wiki-link" %> + <%= link_to "?", wiki_page_path(t.name, z: 2), class: "wiki-link" %> <% end %> <% if show_extra_links && current_query.present? %> - <%= link_to "+", posts_path(tags: "#{current_query} #{t.name}", **search_params), class: "search-inc-tag" %> - <%= link_to "-", posts_path(tags: "#{current_query} -#{t.name}", **search_params), class: "search-exl-tag" %> + <%= link_to "+", posts_path(tags: "#{current_query} #{t.name}", z: 4, **search_params), class: "search-inc-tag" %> + <%= link_to "-", posts_path(tags: "#{current_query} -#{t.name}", z: 4, **search_params), class: "search-exl-tag" %> <% end %> - <%= link_to t.pretty_name, posts_path(tags: t.name, **search_params), class: "search-tag" %> + <%= link_to t.pretty_name, posts_path(tags: t.name, **search_params, z: 2), class: "search-tag" %> <%= tag.span humanized_number(t.post_count), class: "post-count", title: t.post_count %>
  • <% end %> diff --git a/app/views/posts/partials/common/_search.html.erb b/app/views/posts/partials/common/_search.html.erb index 65a27af67..955d86271 100644 --- a/app/views/posts/partials/common/_search.html.erb +++ b/app/views/posts/partials/common/_search.html.erb @@ -13,6 +13,7 @@ <%= hidden_field_tag :size, params[:size] %> <% end %> <%= text_field_tag("tags", tags, :id => tags_dom_id, :class => "flex-auto", :"data-shortcut" => "q", :"data-autocomplete" => "tag-query") %> + <%= hidden_field_tag :z, 5 %> <% end %>