PERF: finalize porting to new incoming links structure

This commit is contained in:
Sam
2014-08-04 16:43:57 +10:00
parent 22768a4b68
commit 03c8f09be8
14 changed files with 145 additions and 23 deletions

View File

@ -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