FIX: only show topic links from active users

This commit is contained in:
Régis Hanol 2016-06-13 11:11:25 +02:00
parent 191d2283f4
commit c13cbc8aea
1 changed files with 5 additions and 4 deletions

View File

@ -237,17 +237,18 @@ class TopicLink < ActiveRecord::Base
end
def self.duplicate_lookup(topic)
results = TopicLink
.includes(:post => :user)
.includes(:post, :user)
.joins(:post, :user)
.where("posts.id IS NOT NULL AND users.id IS NOT NULL")
.where(topic_id: topic.id, reflection: false)
.limit(200)
.last(200)
lookup = {}
results.each do |tl|
normalized = tl.url.downcase.sub(/^https?:\/\//, '').sub(/\/$/, '')
lookup[normalized] = { domain: tl.domain,
username: tl.post.user.username_lower,
username: tl.user.username_lower,
posted_at: tl.post.created_at,
post_number: tl.post.post_number }
end