From 94f70c7b5c2fcfbbef405dcadc88de7ebe8c984c Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 21 May 2018 11:38:29 -0700 Subject: [PATCH] FIX: TopicViewItem: do not store IP of logged in users --- app/models/topic_view_item.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/topic_view_item.rb b/app/models/topic_view_item.rb index fb0cf372b8d..3549825dec8 100644 --- a/app/models/topic_view_item.rb +++ b/app/models/topic_view_item.rb @@ -7,7 +7,7 @@ class TopicViewItem < ActiveRecord::Base validates_presence_of :topic_id, :ip_address, :viewed_at def self.add(topic_id, ip, user_id = nil, at = nil, skip_redis = false) - # Only store a view once per day per thing per user per ip + # Only store a view once per day per thing per (user || ip) at ||= Date.today redis_key = "view:#{topic_id}:#{at}" if user_id @@ -34,6 +34,7 @@ class TopicViewItem < ActiveRecord::Base builder.where("ip_address = :ip_address AND topic_id = :topic_id AND user_id IS NULL") else builder.where("user_id = :user_id AND topic_id = :topic_id") + ip = nil # do not store IP of logged in users end result = builder.exec(topic_id: topic_id, ip_address: ip, viewed_at: at, user_id: user_id)