sportdb 1.8.18 → 1.8.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,20 +7,31 @@ class DateFinder
7
7
  include LogUtils::Logging
8
8
 
9
9
  # todo: make more generic for reuse
10
- MONTH_EN = 'Jan|Feb|March|Mar|April|Apr|May|June|Jun|July|Jul|Aug|Sept|Sep|Oct|Nov|Dec'
10
+ MONTH_EN = 'January|Jan|'+
11
+ 'February|Feb|'+
12
+ 'March|Mar|'+
13
+ 'April|Apr|'+
14
+ 'May|'+
15
+ 'June|Jun|'+
16
+ 'July|Jul|'+
17
+ 'August|Aug|'+
18
+ 'September|Sept|Sep|'+
19
+ 'October|Oct|'+
20
+ 'November|Nov|'+
21
+ 'December|Dec'
11
22
  MONTH_EN_TO_MM = {
12
- 'Jan' => '1',
13
- 'Feb' => '2',
23
+ 'Jan' => '1', 'January' => '1',
24
+ 'Feb' => '2', 'February' => '2',
14
25
  'Mar' => '3', 'March' => '3',
15
26
  'Apr' => '4', 'April' => '4',
16
27
  'May' => '5',
17
28
  'Jun' => '6', 'June' => '6',
18
29
  'Jul' => '7', 'July' => '7',
19
- 'Aug' => '8',
20
- 'Sep' => '9', 'Sept' => '9',
21
- 'Oct' => '10',
22
- 'Nov' => '11',
23
- 'Dec' => '12' }
30
+ 'Aug' => '8', 'August' => '8',
31
+ 'Sep' => '9', 'Sept' => '9', 'September' => '9',
32
+ 'Oct' => '10', 'October' => '10',
33
+ 'Nov' => '11', 'November' => '11',
34
+ 'Dec' => '12', 'December' =>'12' }
24
35
 
25
36
  MONTH_ES = 'Enero|Ene|Feb|Marzo|Mar|Abril|Abr|Mayo|May|Junio|Jun|Julio|Jul|Agosto|Ago|Sept|Set|Sep|Oct|Nov|Dic'
26
37
  MONTH_ES_TO_MM = {
@@ -134,6 +145,19 @@ class DateFinder
134
145
  (?<minutes>\d{2})
135
146
  \b/x
136
147
 
148
+ ###
149
+ # fix: pass in lang (e.g. en or es)
150
+ # only process format for lang plus fallback to en?
151
+ # e.g. EN__DD_MONTH and ES__DD_MONTH depend on order for match (first listed will match)
152
+
153
+ # e.g. 12 May => D|DD.MMM w/ implied year and implied hours
154
+ EN__DD_MONTH__DATE_REGEX = /\b
155
+ (?<day>\d{1,2})
156
+ \s
157
+ (?<month_en>#{MONTH_EN})
158
+ \b/x
159
+
160
+
137
161
  # e.g. Jun/12 2011 14:00
138
162
  EN__MONTH_DD_YYYY__DATE_TIME_REGEX = /\b
139
163
  (?<month_en>#{MONTH_EN})
@@ -197,6 +221,7 @@ class DateFinder
197
221
  [ '[EN_MONTH_DD_hh_mm]', EN__MONTH_DD__DATE_TIME_REGEX ],
198
222
  [ '[EN_MONTH_DD_YYYY]', EN__MONTH_DD_YYYY__DATE_REGEX ],
199
223
  [ '[EN_MONTH_DD]', EN__MONTH_DD__DATE_REGEX ],
224
+ [ '[EN_DD_MONTH]', EN__DD_MONTH__DATE_REGEX ],
200
225
  [ '[ES_DD_MONTH]', ES__DD_MONTH__DATE_REGEX ]
201
226
  ]
202
227
 
@@ -374,14 +374,32 @@ class GameReader
374
374
  ##
375
375
  # note: start_at and end_at are dates ONLY (note datetime)
376
376
  # - do NOT pass in hours etc. in query
377
- # old: date.end_of_day, date.beginning_of_day
378
- # new: date.to_date, date.to_date
379
-
380
- ## pp Round.all
381
-
382
- round = Round.where( 'event_id = ? AND (start_at <= ? AND end_at >= ?)',
377
+ # again use --> date.end_of_day, date.beginning_of_day
378
+ # new: not working: date.to_date, date.to_date
379
+ # will not find round if start_at same as date !! (in theory hours do not matter)
380
+
381
+ ###
382
+ # hack:
383
+ # special case for sqlite3 (date compare not working reliable; use casts)
384
+ # fix: move to adapter_name to activerecord_utils as sqlite? or similar?
385
+
386
+ if ActiveRecord::Base.connection.adapter_name.downcase.starts_with?( 'sqlite' )
387
+ logger.debug( " [sqlite] using sqlite-specific query for date compare for rounds finder" )
388
+ round = Round.where( 'event_id = ? AND ( julianday(start_at) <= julianday(?)'+
389
+ 'AND julianday(end_at) >= julianday(?))',
390
+ @event.id, date.to_date, date.to_date).first
391
+ else # all other dbs (postgresql, mysql, etc.)
392
+ round = Round.where( 'event_id = ? AND (start_at <= ? AND end_at >= ?)',
383
393
  @event.id, date.to_date, date.to_date).first
384
- ## pp round
394
+ end
395
+
396
+ pp round
397
+ if round.nil?
398
+ logger.warn( " !!!! no round match found for date #{date}" )
399
+ pp Round.all
400
+ end
401
+
402
+ ## note: will crash (round.pos) if round is nil
385
403
  logger.debug( " using round #{round.pos} >#{round.title}< start_at: #{round.start_at}, end_at: #{round.end_at}" )
386
404
  else
387
405
  ## use round from last round header
@@ -1,6 +1,6 @@
1
1
 
2
2
  module SportDb
3
- VERSION = '1.8.18'
3
+ VERSION = '1.8.19'
4
4
  end
5
5
 
6
6
 
@@ -27,12 +27,16 @@ class TestDate < MiniTest::Unit::TestCase
27
27
 
28
28
  [ 'Jan/26 2011', '2011-01-26' ],
29
29
  [ 'Jan/26 2011', '2011-01-26 12:00' ],
30
-
30
+
31
31
  [ 'Jan/26', '2013-01-26' ],
32
32
  [ 'Jan/26', '2013-01-26 12:00' ],
33
+ [ '26 January', '2013-01-26' ],
34
+ [ '26 January', '2013-01-26 12:00' ],
33
35
 
34
36
  [ 'Jun/13', '2013-06-13' ],
35
- [ 'Jun/13', '2013-06-13 12:00' ]
37
+ [ 'Jun/13', '2013-06-13 12:00' ],
38
+ [ '13 June', '2013-06-13' ],
39
+ [ '13 June', '2013-06-13 12:00' ]
36
40
  ]
37
41
 
38
42
  assert_dates( data, start_at: DateTime.new( 2013, 1, 1 ) )
@@ -21,6 +21,16 @@ class TestRoundDef < MiniTest::Unit::TestCase
21
21
  title: 'Matchday 1',
22
22
  ko: false,
23
23
  start_at: Date.new( 2014, 6, 12 ) }],
24
+ [ 'Matchday 1 | 12 June',
25
+ { pos:1,
26
+ title: 'Matchday 1',
27
+ ko: false,
28
+ start_at: Date.new( 2014, 6, 12 ) }],
29
+ [ 'Matchday 1 | 13 July',
30
+ { pos:1,
31
+ title: 'Matchday 1',
32
+ ko: false,
33
+ start_at: Date.new( 2014, 7, 13 ) }],
24
34
  [ 'Matchday 13 | Tue Jun/24',
25
35
  { pos: 13,
26
36
  title: 'Matchday 13',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.18
4
+ version: 1.8.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-14 00:00:00.000000000 Z
12
+ date: 2014-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: props
16
- requirement: &74539620 !ruby/object:Gem::Requirement
16
+ requirement: &74965970 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *74539620
24
+ version_requirements: *74965970
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: logutils
27
- requirement: &74538650 !ruby/object:Gem::Requirement
27
+ requirement: &74964650 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *74538650
35
+ version_requirements: *74964650
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: textutils
38
- requirement: &74537420 !ruby/object:Gem::Requirement
38
+ requirement: &74963290 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *74537420
46
+ version_requirements: *74963290
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: worlddb
49
- requirement: &74534960 !ruby/object:Gem::Requirement
49
+ requirement: &74957330 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.0.2
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *74534960
57
+ version_requirements: *74957330
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: tagutils
60
- requirement: &74532380 !ruby/object:Gem::Requirement
60
+ requirement: &74956650 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *74532380
68
+ version_requirements: *74956650
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fetcher
71
- requirement: &74526380 !ruby/object:Gem::Requirement
71
+ requirement: &74954700 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0.3'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *74526380
79
+ version_requirements: *74954700
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: gli
82
- requirement: &74524870 !ruby/object:Gem::Requirement
82
+ requirement: &75046310 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 2.5.6
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *74524870
90
+ version_requirements: *75046310
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: activerecord
93
- requirement: &74524290 !ruby/object:Gem::Requirement
93
+ requirement: &75044290 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *74524290
101
+ version_requirements: *75044290
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdoc
104
- requirement: &74522390 !ruby/object:Gem::Requirement
104
+ requirement: &75043540 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '4.0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *74522390
112
+ version_requirements: *75043540
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: hoe
115
- requirement: &74519770 !ruby/object:Gem::Requirement
115
+ requirement: &75042130 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '3.11'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *74519770
123
+ version_requirements: *75042130
124
124
  description: sportdb - sport.db command line tool
125
125
  email: opensport@googlegroups.com
126
126
  executables: