BUGFIX: new date was incorrect
This commit is contained in:
parent
f9cd354a2c
commit
4b61d6af28
|
@ -83,11 +83,11 @@ class TopicTrackingState
|
|||
end
|
||||
|
||||
def self.treat_as_new_topic_clause
|
||||
User.where("CASE
|
||||
WHEN COALESCE(u.new_topic_duration_minutes, :default_duration) = :always THEN us.new_since
|
||||
WHEN COALESCE(u.new_topic_duration_minutes, :default_duration) = :last_visit THEN COALESCE(u.previous_visit_at,us.new_since)
|
||||
User.where("GREATEST(CASE
|
||||
WHEN COALESCE(u.new_topic_duration_minutes, :default_duration) = :always THEN u.created_at
|
||||
WHEN COALESCE(u.new_topic_duration_minutes, :default_duration) = :last_visit THEN COALESCE(u.previous_visit_at,u.created_at)
|
||||
ELSE (:now::timestamp - INTERVAL '1 MINUTE' * COALESCE(u.new_topic_duration_minutes, :default_duration))
|
||||
END",
|
||||
END, us.new_since)",
|
||||
now: DateTime.now,
|
||||
last_visit: User::NewTopicDuration::LAST_VISIT,
|
||||
always: User::NewTopicDuration::ALWAYS,
|
||||
|
|
|
@ -464,14 +464,14 @@ class User < ActiveRecord::Base
|
|||
|
||||
def treat_as_new_topic_start_date
|
||||
duration = new_topic_duration_minutes || SiteSetting.new_topic_duration_minutes
|
||||
case duration
|
||||
[case duration
|
||||
when User::NewTopicDuration::ALWAYS
|
||||
user_stat.new_since
|
||||
created_at
|
||||
when User::NewTopicDuration::LAST_VISIT
|
||||
previous_visit_at || user_stat.new_since
|
||||
else
|
||||
duration.minutes.ago
|
||||
end
|
||||
end, user_stat.new_since].max
|
||||
end
|
||||
|
||||
def readable_name
|
||||
|
|
Loading…
Reference in New Issue