better check for forum post votability

This commit is contained in:
Albert Yi 2019-01-28 17:23:33 -08:00
parent 9fda456b7d
commit caf60d690d
2 changed files with 11 additions and 1 deletions

View File

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

View File

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