Refactor Reaction model (#11138)

Deleted unused methods that are not found/used across the repository in the Reaction model
This commit is contained in:
WenYu 2020-10-29 21:25:43 +08:00 committed by GitHub
parent 540bc1fd84
commit e0e410e9e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,11 +81,7 @@ class Reaction < ApplicationRecord
end
def target_user
if reactable_type == "User"
reactable
else
reactable.user
end
reactable_type == "User" ? reactable : reactable.user
end
def negative?
@ -94,10 +90,6 @@ class Reaction < ApplicationRecord
private
def indexable?
category == "readinglist" && reactable && reactable.published
end
def update_reactable
Reactions::UpdateReactableWorker.perform_async(id)
end
@ -122,40 +114,6 @@ class Reaction < ApplicationRecord
reactable.reading_time if category == "readinglist"
end
def reactable_user
return unless category == "readinglist"
{
username: reactable.user_username,
name: reactable.user_name,
profile_image_90: reactable.user.profile_image_90
}
end
def reactable_published_date
reactable.readable_publish_date if category == "readinglist"
end
def searchable_reactable_title
reactable.title if category == "readinglist"
end
def searchable_reactable_text
reactable.body_text[0..350] if category == "readinglist"
end
def searchable_reactable_tags
reactable.cached_tag_list if category == "readinglist"
end
def searchable_reactable_path
reactable.path if category == "readinglist"
end
def reactable_tags
reactable.decorate.cached_tag_list_array if category == "readinglist"
end
def viewable_by
user_id
end