Skip to content

Commit

Permalink
Add reading time to reading list (forem#2929)
Browse files Browse the repository at this point in the history
* init

- add reading_time to reactions
- make migration
- add to algolia index in reaction model
- add method in reaction model to define reading time based on reactable reading time

* add time to front end

* Revert "Return errors instead of raising an exception on ArticleCreation (forem#2922)"

This reverts commit 09a99d9.

* Revert "init"

This reverts commit 53650eb.

* Revert "Revert "Return errors instead of raising an exception on ArticleCreation (forem#2922)""

This reverts commit e8cf1f3.

* Update reaction.rb

* remove duplicate searchableAttribute
  • Loading branch information
mariocsee authored and benhalpern committed May 31, 2019
1 parent 1775f42 commit 8359ab5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/javascript/readingList/readingList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export class ReadingList extends Component {
src={item.reactable_user.profile_image_90}
alt="Profile Pic"
/>
{item.reactable_user.name}{item.reactable_published_date}
{item.reactable_user.name}{item.reactable_published_date}
{item.reading_time} min read・
</a>
<span className="readinglist-item-tag-collection">
{item.reactable_tags.map(tag => (
Expand Down
8 changes: 6 additions & 2 deletions app/models/reaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class Reaction < ApplicationRecord
before_destroy :remove_algolia

algoliasearch index_name: "SecuredReactions_#{Rails.env}", auto_index: false, auto_remove: false do
attribute :id, :reactable_user, :searchable_reactable_title, :searchable_reactable_path, :status,
attribute :id, :reactable_user, :searchable_reactable_title, :searchable_reactable_path, :status, :reading_time,
:searchable_reactable_text, :searchable_reactable_tags, :viewable_by, :reactable_tags, :reactable_published_date
searchableAttributes %i[searchable_reactable_title searchable_reactable_text
searchable_reactable_text searchable_reactable_tags reactable_user]
searchable_reactable_tags reactable_user]
tags do
reactable_tags
end
Expand Down Expand Up @@ -105,6 +105,10 @@ def update_reactable_without_delay
Reactions::UpdateReactableJob.perform_now(id)
end

def reading_time
reactable.reading_time if category == "readinglist"
end

def remove_from_index
remove_from_index!
end
Expand Down

0 comments on commit 8359ab5

Please sign in to comment.