sportdb-importers 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/sportdb/importers.rb +4 -4
- data/lib/sportdb/importers/import.rb +15 -10
- data/lib/sportdb/importers/version.rb +2 -2
- data/test/test_import.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03d3875605ad42d0fd7876f036c2bbbe2dd8999d
|
4
|
+
data.tar.gz: 92435a82e496ef1ca09a9e44395038a81c7b5b21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac4fea2f6fc7b2fc7d5d981e792977bd1bb44ae8de3bcd72bacae4583828f02f76a1785f9e91f7d68036e10b4743f1cd561e610b1e41612b058c634f5f1b1537
|
7
|
+
data.tar.gz: 2ff8b5dc6f53994431cba566e2031834aa61fd2d6f668a8d4a61af177783791b4981946b58e587ddd2a199f8fa6469ce006925b607111529359503afc627479e
|
data/Rakefile
CHANGED
data/lib/sportdb/importers.rb
CHANGED
@@ -33,10 +33,10 @@ def read_csv( start: nil ) ### todo/fix - rename to read_csv !!!!!!
|
|
33
33
|
event = CsvEventImporter.parse( entry.read, league: league_key,
|
34
34
|
season: season_key )
|
35
35
|
|
36
|
-
puts "added #{event.
|
36
|
+
puts "added #{event.name} - from source >#{entry.name}<"
|
37
37
|
puts " #{event.teams.size} teams"
|
38
|
+
puts " #{event.matches.size} matches"
|
38
39
|
puts " #{event.rounds.size} rounds"
|
39
|
-
puts " #{event.games.size} games"
|
40
40
|
end # each datafile
|
41
41
|
end # each season
|
42
42
|
end # method import
|
@@ -63,10 +63,10 @@ def self.read_csv( path )
|
|
63
63
|
event = CsvEventImporter.read( full_path, league: league_key,
|
64
64
|
season: season_key )
|
65
65
|
|
66
|
-
puts "added #{event.
|
66
|
+
puts "added #{event.name} - from source >#{path}<"
|
67
67
|
puts " #{event.teams.size} teams"
|
68
|
+
puts " #{event.matches.size} matches"
|
68
69
|
puts " #{event.rounds.size} rounds"
|
69
|
-
puts " #{event.games.size} games"
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end # module SportDb
|
@@ -92,12 +92,12 @@ class CsvEventImporter
|
|
92
92
|
|
93
93
|
|
94
94
|
## add catch-all/unclassified "dummy" round
|
95
|
-
round_rec = Model::Round.create!(
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
)
|
95
|
+
# round_rec = Model::Round.create!(
|
96
|
+
# event_id: event_rec.id,
|
97
|
+
# title: 'Matchday ??? / Missing / Catch-All', ## find a better name?
|
98
|
+
# pos: 999,
|
99
|
+
# start_at: event_rec.start_at.to_date
|
100
|
+
# )
|
101
101
|
|
102
102
|
## add matches
|
103
103
|
matches.each do |match|
|
@@ -108,12 +108,17 @@ class CsvEventImporter
|
|
108
108
|
puts "!!! WARN: skipping match - play date missing!!!!!"
|
109
109
|
pp match
|
110
110
|
else
|
111
|
-
|
111
|
+
## find last pos - check if it can be nil? yes, is nil if no records found
|
112
|
+
max_pos = Model::Match.where( event_id: event_rec.id ).maximum( 'pos' )
|
113
|
+
max_pos = max_pos ? max_pos+1 : 1
|
114
|
+
|
115
|
+
rec = Model::Match.create!(
|
116
|
+
event_id: event_rec.id,
|
112
117
|
team1_id: team1_rec.id,
|
113
118
|
team2_id: team2_rec.id,
|
114
|
-
round_id: round_rec.id,
|
115
|
-
pos:
|
116
|
-
|
119
|
+
## round_id: round_rec.id, -- note: now optional
|
120
|
+
pos: max_pos,
|
121
|
+
date: Date.strptime( match.date, '%Y-%m-%d' ),
|
117
122
|
score1: match.score1,
|
118
123
|
score2: match.score2,
|
119
124
|
score1i: match.score1i,
|
data/test/test_import.rb
CHANGED
@@ -41,9 +41,9 @@ class TestImport < MiniTest::Test
|
|
41
41
|
)
|
42
42
|
|
43
43
|
assert_equal 20, event_rec.teams.count
|
44
|
-
assert_equal 380, event_rec.
|
44
|
+
assert_equal 380, event_rec.matches.count
|
45
45
|
|
46
|
-
rec = event_rec.
|
46
|
+
rec = event_rec.matches.first
|
47
47
|
assert_equal 'Arsenal FC', rec.team1.name
|
48
48
|
assert_equal 'Leicester City FC', rec.team2.name
|
49
49
|
assert_equal 4, rec.score1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-importers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-sync
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|