mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 22:15:35 +08:00
PERF: finalize porting to new incoming links structure
This commit is contained in:
@ -1,4 +1,22 @@
|
||||
class IncomingReferer < ActiveRecord::Base
|
||||
belongs_to :incoming_domain
|
||||
|
||||
def self.add!(opts)
|
||||
domain_id = opts[:incoming_domain_id]
|
||||
domain_id ||= opts[:incoming_domain].id
|
||||
path = opts[:path]
|
||||
|
||||
current = find_by(path: path, incoming_domain_id: domain_id)
|
||||
return current if current
|
||||
|
||||
begin
|
||||
current = create!(path: path, incoming_domain_id: domain_id)
|
||||
rescue
|
||||
# duplicates
|
||||
end
|
||||
|
||||
current || find_by(path: path, incoming_domain_id: domain_id)
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
Reference in New Issue
Block a user