optimize query for fetching PM created in previous hour
This commit is contained in:
parent
8229cc2ff1
commit
345b453ee1
|
@ -496,8 +496,7 @@ class TopicView
|
||||||
raise Discourse::InvalidAccess.new("can't see #{@topic}", @topic) unless @guardian.can_see?(@topic)
|
raise Discourse::InvalidAccess.new("can't see #{@topic}", @topic) unless @guardian.can_see?(@topic)
|
||||||
# log personal message views
|
# log personal message views
|
||||||
if SiteSetting.log_personal_messages_views && @topic.present? && @topic.private_message? && @topic.all_allowed_users.where(id: @user.id).blank?
|
if SiteSetting.log_personal_messages_views && @topic.present? && @topic.private_message? && @topic.all_allowed_users.where(id: @user.id).blank?
|
||||||
last_pm_log = UserHistory.where(acting_user_id: @user.id, action: UserHistory.actions[:check_personal_message], topic_id: @topic.id).order(created_at: :desc).first
|
unless UserHistory.where(acting_user_id: @user.id, action: UserHistory.actions[:check_personal_message], topic_id: @topic.id).where("created_at > ?", 1.hour.ago).exists?
|
||||||
unless last_pm_log.present? && last_pm_log.created_at > 1.hour.ago
|
|
||||||
StaffActionLogger.new(@user).log_check_personal_message(@topic)
|
StaffActionLogger.new(@user).log_check_personal_message(@topic)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue