Potential improvement for #read_by?

This commit is contained in:
Toks
2014-03-29 21:27:46 -04:00
parent 421adfc65c
commit 57f82182a8

View File

@@ -106,6 +106,7 @@ class ForumTopic < ActiveRecord::Base
end
def read_by?(user, read_forum_topic_ids)
return true if updated_at < user.last_forum_read_at
if read_forum_topic_ids.any? {|topic_id, timestamp| id.to_s == topic_id && updated_at.to_i > timestamp.to_i}
return false
end
@@ -113,7 +114,6 @@ class ForumTopic < ActiveRecord::Base
return true
end
return false if user.last_forum_read_at.nil?
return true if updated_at < user.last_forum_read_at
return false
end