diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index b885998ae..06ee93fe3 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -125,7 +125,9 @@ class ForumPost < ApplicationRecord end def votable? - body.to_s.match?(/->/) + TagAlias.where(forum_post_id: id).exists? || + TagImplication.where(forum_post_id: id).exists? || + BulkUpdateRequest.where(forum_post_id: id).exists? end def voted?(user, score) diff --git a/db/migrate/20190129012253_add_tag_relationship_forum_post_indices.rb b/db/migrate/20190129012253_add_tag_relationship_forum_post_indices.rb new file mode 100644 index 000000000..1d8fa8237 --- /dev/null +++ b/db/migrate/20190129012253_add_tag_relationship_forum_post_indices.rb @@ -0,0 +1,8 @@ +class AddTagRelationshipForumPostIndices < ActiveRecord::Migration[5.2] + def change + execute "set statement_timeout = 0" + add_index :tag_aliases, :forum_post_id + add_index :tag_implications, :forum_post_id + add_index :bulk_update_requests, :forum_post_id + end +end