mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user