mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 11:19:51 +00:00
FIX: Use custom date for redis key in TopicViewItem.add
.
This commit is contained in:
parent
d39faf7ddf
commit
5fb405cca2
@ -8,7 +8,8 @@ class TopicViewItem < ActiveRecord::Base
|
||||
|
||||
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
|
||||
redis_key = "view:#{topic_id}:#{Date.today}"
|
||||
at ||= Date.today
|
||||
redis_key = "view:#{topic_id}:#{at}"
|
||||
if user_id
|
||||
redis_key << ":user-#{user_id}"
|
||||
else
|
||||
@ -19,8 +20,6 @@ class TopicViewItem < ActiveRecord::Base
|
||||
skip_redis || $redis.expire(redis_key, SiteSetting.topic_view_duration_hours.hours)
|
||||
|
||||
TopicViewItem.transaction do
|
||||
at ||= Date.today
|
||||
|
||||
# this is called real frequently, working hard to avoid exceptions
|
||||
sql = "INSERT INTO topic_views (topic_id, ip_address, viewed_at, user_id)
|
||||
SELECT :topic_id, :ip_address, :viewed_at, :user_id
|
||||
|
Loading…
x
Reference in New Issue
Block a user