wiki pages: drop creator and updater fields.

Drop the creator_id and updater_id fields from wiki pages. These fields
had several issues:

* The creator_id field was inconsistent with the wiki_page_versions
  table. Apparently during the migration to Danbooru 2 in 2012-2013 the
  creator_id field got reset to whoever last updated the wiki at that
  point in time.

* Saving a wiki would set the updater_id even when nothing actually
  changed. This also caused the updated_at timestamp to get bumped.
  Because of this, anything that saved a wiki, including things like
  creating aliases or implications, would bump the updater_id and
  updated_at even though the wiki didn't actually change. This meant
  these fields weren't consistent with the wiki_page_versions history.

Changes:

* Remove `creator_name` field from the /wiki_pages.json API.
* Remove creator name search option from /wiki_pages/search.
This commit is contained in:
evazion
2019-10-24 14:49:09 -05:00
parent 97a758dec6
commit a0b6c9b116
7 changed files with 12 additions and 15 deletions

View File

@@ -15,14 +15,12 @@ class WikiPage < ApplicationRecord
attr_accessor :skip_secondary_validations
array_attribute :other_names
belongs_to_creator
belongs_to_updater
has_one :tag, :foreign_key => "name", :primary_key => "title"
has_one :artist, -> {where(:is_active => true)}, :foreign_key => "name", :primary_key => "title"
has_many :versions, -> {order("wiki_page_versions.id ASC")}, :class_name => "WikiPageVersion", :dependent => :destroy
has_many :dtext_links, as: :model, dependent: :destroy
api_attributes including: [:creator_name, :category_name]
api_attributes including: [:category_name]
module SearchMethods
def titled(title)
@@ -63,7 +61,7 @@ class WikiPage < ApplicationRecord
def search(params = {})
q = super
q = q.search_attributes(params, :creator, :updater, :is_locked, :is_deleted, :body)
q = q.search_attributes(params, :is_locked, :is_deleted, :body)
q = q.text_attribute_matches(:body, params[:body_matches], index_column: :body_index, ts_config: "danbooru")
if params[:title].present?
@@ -102,10 +100,6 @@ class WikiPage < ApplicationRecord
end
end
def creator_name
creator.name
end
extend SearchMethods
def validate_not_locked