db: remove tag_aliases.post_count column.
This was only used in autocomplete, but it was unnecessary here because we could already get the post count from the tags table.
This commit is contained in:
@@ -14,7 +14,6 @@ module DanbooruMaintenance
|
||||
Delayed::Job.where('created_at < ?', 45.days.ago).delete_all
|
||||
PostDisapproval.prune!
|
||||
ForumSubscription.process_all!
|
||||
TagAlias.update_cached_post_counts_for_all
|
||||
PostDisapproval.dmail_messages!
|
||||
regenerate_post_counts!
|
||||
SuperVoter.init!
|
||||
|
||||
@@ -895,7 +895,7 @@ class Tag < ApplicationRecord
|
||||
q
|
||||
end
|
||||
|
||||
def names_matches_with_aliases(name, limit: 10)
|
||||
def names_matches_with_aliases(name, limit)
|
||||
name = normalize_name(name)
|
||||
wildcard_name = name + '*'
|
||||
|
||||
@@ -907,8 +907,8 @@ class Tag < ApplicationRecord
|
||||
.where("tag_aliases.antecedent_name LIKE ? ESCAPE E'\\\\'", wildcard_name.to_escaped_for_sql_like)
|
||||
.active
|
||||
.where("tags.name NOT LIKE ? ESCAPE E'\\\\'", wildcard_name.to_escaped_for_sql_like)
|
||||
.where("tag_aliases.post_count > 0")
|
||||
.order("tag_aliases.post_count desc")
|
||||
.where("tags.post_count > 0")
|
||||
.order("tags.post_count desc")
|
||||
.limit(limit * 2) # Get extra records in case some duplicates get filtered out.
|
||||
|
||||
sql_query = "((#{query1.to_sql}) UNION ALL (#{query2.to_sql})) AS unioned_query"
|
||||
|
||||
@@ -64,7 +64,7 @@ class TagAlias < TagRelationship
|
||||
update_posts
|
||||
forum_updater.update(approval_message(approver), "APPROVED") if update_topic
|
||||
rename_wiki_and_artist
|
||||
update(status: "active", post_count: consequent_tag.post_count)
|
||||
update(status: "active")
|
||||
end
|
||||
rescue Exception => e
|
||||
if tries < 5
|
||||
@@ -183,10 +183,6 @@ class TagAlias < TagRelationship
|
||||
end
|
||||
end
|
||||
|
||||
def self.update_cached_post_counts_for_all
|
||||
execute_sql("UPDATE tag_aliases SET post_count = tags.post_count FROM tags WHERE tags.name = tag_aliases.consequent_name")
|
||||
end
|
||||
|
||||
def create_mod_action
|
||||
alias_desc = %Q("tag alias ##{id}":[#{Rails.application.routes.url_helpers.tag_alias_path(self)}]: [[#{antecedent_name}]] -> [[#{consequent_name}]])
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class DropPostCountFromTagAliases < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
remove_index :tag_aliases, :post_count
|
||||
remove_column :tag_aliases, :post_count, :integer, null: false, default: 0
|
||||
end
|
||||
end
|
||||
@@ -2887,7 +2887,6 @@ CREATE TABLE public.tag_aliases (
|
||||
status text DEFAULT 'pending'::text NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
post_count integer DEFAULT 0 NOT NULL,
|
||||
approver_id integer,
|
||||
forum_post_id integer
|
||||
);
|
||||
@@ -6901,13 +6900,6 @@ CREATE INDEX index_tag_aliases_on_consequent_name ON public.tag_aliases USING bt
|
||||
CREATE INDEX index_tag_aliases_on_forum_post_id ON public.tag_aliases USING btree (forum_post_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_tag_aliases_on_post_count; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_tag_aliases_on_post_count ON public.tag_aliases USING btree (post_count);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_tag_implications_on_antecedent_name; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -7404,6 +7396,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20191116224228'),
|
||||
('20191117074642'),
|
||||
('20191117080647'),
|
||||
('20191117081229');
|
||||
('20191117081229'),
|
||||
('20191117200404');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user