wiki pages: remove category_name field from API.
Remove the `category_name` field from the `/wiki_page.json` API. This field was originally added only because it was needed by our autocomplete Javascript. It was also misnamed, it wasn't the tag's category name, it was the category's ID. Users should use `https://danbooru.donmai.us/wiki_pages.json?only=title,tag` instead if they need this. This triggered a N+1 query pattern when dumping wiki pages to BigQuery, which made dumping wiki pages very slow. It also meant this field was included in the database dump, even though it wasn't a real database column.
This commit is contained in:
@@ -162,10 +162,6 @@ class WikiPage < ApplicationRecord
|
||||
name.to_s.unicode_normalize(:nfkc).normalize_whitespace.gsub(/[[:space:]]+/, "_").squeeze("_").gsub(/\A_|_\z/, "")
|
||||
end
|
||||
|
||||
def category_name
|
||||
tag&.category
|
||||
end
|
||||
|
||||
def pretty_title
|
||||
title.tr("_", " ")
|
||||
end
|
||||
|
||||
@@ -14,12 +14,4 @@ class WikiPagePolicy < ApplicationPolicy
|
||||
def permitted_attributes
|
||||
[:title, :body, :other_names, :other_names_string, :is_deleted, (:is_locked if can_edit_locked?)].compact
|
||||
end
|
||||
|
||||
def api_attributes
|
||||
super + [:category_name]
|
||||
end
|
||||
|
||||
def html_data_attributes
|
||||
super + [:category_name]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<%= render "wiki_pages/sidebar" %>
|
||||
|
||||
<% content_for(:content) do %>
|
||||
<h1>Wiki Page Version Comparison: <%= link_to @thispage.title, wiki_page_versions_path(search: { wiki_page_id: @thispage.wiki_page_id }, type: params[:type], anchor: "wiki-page-version-#{@thispage.id}"), class: "tag-type-#{@thispage.wiki_page.category_name}" %></h1>
|
||||
<h1>Wiki Page Version Comparison: <%= link_to @thispage.title, wiki_page_versions_path(search: { wiki_page_id: @thispage.wiki_page_id }, type: params[:type], anchor: "wiki-page-version-#{@thispage.id}"), class: "tag-type-#{@thispage.wiki_page.tag.category}" %></h1>
|
||||
|
||||
<% if params[:type].present? %>
|
||||
<%= render "versions/types" %>
|
||||
|
||||
Reference in New Issue
Block a user