7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/sportdb/readers/sync/more.rb', line 7
def self.find_or_create( team )
rec = Model::Team.find_by( name: team.name )
if rec.nil?
puts "add national team: #{team.key}, #{team.name}, #{team.country.name} (#{team.country.key})"
attribs = {
key: team.key, name: team.name,
code: team.code,
country_id: Sync::Country.find_or_create( team.country ).id,
club: false,
national: true }
if team.alt_names.empty? == false
attribs[:alt_names] = team.alt_names.join('|')
end
rec = Model::Team.create!( attribs )
end
rec
end
|