From e356fd0fd5d64d99ac0be5dec1464201e1b20a39 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 7 Jan 2021 02:24:30 -0600 Subject: [PATCH] models: remove nonexistent associations. Remove the WikiPageVersion#artist and Post#updater associations. Neither of these existed and they caused problems with searching includable associations in the API. --- app/models/post.rb | 3 +-- app/models/wiki_page_version.rb | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 60b2b8730..9e0854260 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -39,7 +39,6 @@ class Post < ApplicationRecord after_commit :remove_iqdb_async, :on => :destroy after_commit :update_iqdb_async, :on => :create - belongs_to :updater, :class_name => "User", optional: true # this is handled in versions belongs_to :approver, class_name: "User", optional: true belongs_to :uploader, :class_name => "User", :counter_cache => "post_upload_count" belongs_to :parent, class_name: "Post", optional: true @@ -1295,7 +1294,7 @@ class Post < ApplicationRecord :is_note_locked, :is_rating_locked, :is_status_locked, :is_pending, :is_flagged, :is_deleted, :is_banned, :last_comment_bumped_at, :last_commented_at, :last_noted_at, :uploader_ip_addr, - :uploader, :updater, :approver, :parent, :upload, :artist_commentary, + :uploader, :approver, :parent, :upload, :artist_commentary, :flags, :appeals, :notes, :comments, :children, :approvals, :replacements, :pixiv_ugoira_frame_data ) diff --git a/app/models/wiki_page_version.rb b/app/models/wiki_page_version.rb index 1f405d4f1..945688e24 100644 --- a/app/models/wiki_page_version.rb +++ b/app/models/wiki_page_version.rb @@ -2,12 +2,11 @@ class WikiPageVersion < ApplicationRecord array_attribute :other_names belongs_to :wiki_page belongs_to_updater - belongs_to :artist, optional: true belongs_to :tag, primary_key: :name, foreign_key: :title, optional: true module SearchMethods def search(params) - q = search_attributes(params, :id, :created_at, :updated_at, :title, :body, :other_names, :is_locked, :is_deleted, :updater, :wiki_page, :artist, :tag) + q = search_attributes(params, :id, :created_at, :updated_at, :title, :body, :other_names, :is_locked, :is_deleted, :updater, :wiki_page, :tag) q = q.text_attribute_matches(:title, params[:title_matches]) q = q.text_attribute_matches(:body, params[:body_matches]) @@ -76,6 +75,6 @@ class WikiPageVersion < ApplicationRecord end def self.available_includes - [:updater, :wiki_page, :artist, :tag] + [:updater, :wiki_page, :tag] end end