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.
This commit is contained in:
evazion
2022-01-12 10:25:35 -06:00
parent 7c32b8b503
commit c1a1741d20
4 changed files with 14 additions and 13 deletions

View File

@@ -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

View File

@@ -8,19 +8,19 @@
<% tags.each do |t| %>
<li class="tag-type-<%= t.category %>" data-tag-name="<%= t.name %>">
<% 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 %>
</li>

View File

@@ -3,19 +3,19 @@
<li class="tag-type-<%= t.category %>" data-tag-name="<%= t.name %>">
<%# 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 %>
</li>
<% end %>

View File

@@ -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 %>
<button id="search-box-submit" type="submit"><%= search_icon %></button>
<% end %>
</section>