FIX: Set a minimum reading time per post. (#7842)

Topics containing only images could generate a reading time of zero minutes.
This commit is contained in:
Bianca Nenciu
2019-07-19 18:15:38 +03:00
committed by GitHub
parent 5a3a6824c4
commit 9ba2c7cd8b
3 changed files with 33 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ require_dependency 'gaps'
class TopicView
MEGA_TOPIC_POSTS_COUNT = 10000
MIN_POST_READ_TIME = 4.0
attr_reader(
:topic,
@@ -208,7 +209,13 @@ class TopicView
def read_time
return nil if @post_number > 1 # only show for topic URLs
(@topic.word_count / SiteSetting.read_time_word_count).floor if @topic.word_count
if @topic.word_count && SiteSetting.read_time_word_count > 0
[
@topic.word_count / SiteSetting.read_time_word_count,
@topic.posts_count * MIN_POST_READ_TIME / 60
].max.ceil
end
end
def like_count