FIX: only show topic links from active users
This commit is contained in:
parent
191d2283f4
commit
c13cbc8aea
|
@ -237,17 +237,18 @@ class TopicLink < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.duplicate_lookup(topic)
|
def self.duplicate_lookup(topic)
|
||||||
|
|
||||||
results = TopicLink
|
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)
|
.where(topic_id: topic.id, reflection: false)
|
||||||
.limit(200)
|
.last(200)
|
||||||
|
|
||||||
lookup = {}
|
lookup = {}
|
||||||
results.each do |tl|
|
results.each do |tl|
|
||||||
normalized = tl.url.downcase.sub(/^https?:\/\//, '').sub(/\/$/, '')
|
normalized = tl.url.downcase.sub(/^https?:\/\//, '').sub(/\/$/, '')
|
||||||
lookup[normalized] = { domain: tl.domain,
|
lookup[normalized] = { domain: tl.domain,
|
||||||
username: tl.post.user.username_lower,
|
username: tl.user.username_lower,
|
||||||
posted_at: tl.post.created_at,
|
posted_at: tl.post.created_at,
|
||||||
post_number: tl.post.post_number }
|
post_number: tl.post.post_number }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue