sportdb-importers 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a21cdc02ddf3bef0f067f6bab0d369d0618ac0c
4
- data.tar.gz: bd325b2ce078afaa1ecc32a8ab2280dd463b22e8
3
+ metadata.gz: 03d3875605ad42d0fd7876f036c2bbbe2dd8999d
4
+ data.tar.gz: 92435a82e496ef1ca09a9e44395038a81c7b5b21
5
5
  SHA512:
6
- metadata.gz: 320f53db2ab141a2994f7b0b8280daef4b066a951894270228c1671f10498db7c4e502f4418f588155b21309086c240ed92ed135318098167ff4225e5dda5f46
7
- data.tar.gz: fc0b0adeeae78f515e7c6b1a8d6878dfc21b62d3c6ff1fef8155225a0a23551bd2e9c330e687b737a2e5c16880fd625220dd28d2dae21d15ccd144582f0a5f1b
6
+ metadata.gz: ac4fea2f6fc7b2fc7d5d981e792977bd1bb44ae8de3bcd72bacae4583828f02f76a1785f9e91f7d68036e10b4743f1cd561e610b1e41612b058c634f5f1b1537
7
+ data.tar.gz: 2ff8b5dc6f53994431cba566e2031834aa61fd2d6f668a8d4a61af177783791b4981946b58e587ddd2a199f8fa6469ce006925b607111529359503afc627479e
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ Hoe.spec 'sportdb-importers' do
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['sportdb-sync', '>= 1.0.0'],
23
+ ['sportdb-sync', '>= 1.1.0'],
24
24
  ]
25
25
 
26
26
  self.spec_extras = {
@@ -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.title} - from source >#{entry.name}<"
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.title} - from source >#{path}<"
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
- 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
- )
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
- rec = Model::Game.create!(
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: 999, ## make optional why? why not? - change to num?
116
- play_at: Date.strptime( match.date, '%Y-%m-%d' ),
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,
@@ -6,8 +6,8 @@ module Module
6
6
  module Importers
7
7
 
8
8
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
9
- MINOR = 0
10
- PATCH = 1
9
+ MINOR = 1
10
+ PATCH = 0
11
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
12
 
13
13
  def self.version
@@ -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.games.count
44
+ assert_equal 380, event_rec.matches.count
45
45
 
46
- rec = event_rec.games.first
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.1
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-05-16 00:00:00.000000000 Z
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.0.0
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.0.0
26
+ version: 1.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement