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:
evazion
2019-11-17 14:14:17 -06:00
parent a2ea2a65a1
commit 64728c89d8
5 changed files with 12 additions and 18 deletions

View File

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

View File

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

View File

@@ -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}]])