mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
BUGFIX: new date was incorrect
This commit is contained in:
parent
f9cd354a2c
commit
4b61d6af28
2 changed files with 7 additions and 7 deletions
|
@ -83,11 +83,11 @@ class TopicTrackingState
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.treat_as_new_topic_clause
|
def self.treat_as_new_topic_clause
|
||||||
User.where("CASE
|
User.where("GREATEST(CASE
|
||||||
WHEN COALESCE(u.new_topic_duration_minutes, :default_duration) = :always THEN us.new_since
|
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,us.new_since)
|
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))
|
ELSE (:now::timestamp - INTERVAL '1 MINUTE' * COALESCE(u.new_topic_duration_minutes, :default_duration))
|
||||||
END",
|
END, us.new_since)",
|
||||||
now: DateTime.now,
|
now: DateTime.now,
|
||||||
last_visit: User::NewTopicDuration::LAST_VISIT,
|
last_visit: User::NewTopicDuration::LAST_VISIT,
|
||||||
always: User::NewTopicDuration::ALWAYS,
|
always: User::NewTopicDuration::ALWAYS,
|
||||||
|
|
|
@ -464,14 +464,14 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
def treat_as_new_topic_start_date
|
def treat_as_new_topic_start_date
|
||||||
duration = new_topic_duration_minutes || SiteSetting.new_topic_duration_minutes
|
duration = new_topic_duration_minutes || SiteSetting.new_topic_duration_minutes
|
||||||
case duration
|
[case duration
|
||||||
when User::NewTopicDuration::ALWAYS
|
when User::NewTopicDuration::ALWAYS
|
||||||
user_stat.new_since
|
created_at
|
||||||
when User::NewTopicDuration::LAST_VISIT
|
when User::NewTopicDuration::LAST_VISIT
|
||||||
previous_visit_at || user_stat.new_since
|
previous_visit_at || user_stat.new_since
|
||||||
else
|
else
|
||||||
duration.minutes.ago
|
duration.minutes.ago
|
||||||
end
|
end, user_stat.new_since].max
|
||||||
end
|
end
|
||||||
|
|
||||||
def readable_name
|
def readable_name
|
||||||
|
|
Loading…
Reference in a new issue