Skip to content

Commit 54e62f9

Browse files
committed
undle updates & rubocop updates; moved zero?, positive? & present? helpers directly into TimingManageable; specs updates
1 parent bdeaef1 commit 54e62f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+269
-144
lines changed

.rubocop.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ RSpec/PendingWithoutReason:
141141
Exclude:
142142
- 'spec/models/goggles_db/goggle_cup*'
143143

144+
# Yields an error with:
145+
# - v. 1.68.0 (using Parser 3.3.6.0, rubocop-ast 1.36.1, analyzing as Ruby 3.1, running on ruby 3.1.4)
146+
Style/BitwisePredicate:
147+
Enabled: false
148+
144149
Style/Documentation:
145150
Exclude:
146151
- 'db/migrate/**/*'

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
_Please, add the latest build info on top of the list; use Version::MAJOR only after gold release; keep semantic versioning in line with framework's_
44

5+
- **0.7.24** [Steve A.] bundle updates & rubocop updates; moved zero?, positive? & present? helpers directly into TimingManageable; specs updates
56
- **0.7.23** [Steve A.] bundle updates
67
- **0.7.20** [Steve A.] bundle updates; added a missing/new EventType used for Coopernuoto meetings ('6X50SL')
78
- **0.7.19** [Steve A.] bundle updates; added new Seasons & categories for 2024-2025

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ group :development do
3636
gem 'rubocop'
3737
gem 'rubocop-factory_bot', require: false
3838
gem 'rubocop-performance'
39-
gem 'rubocop-rails', '= 2.19', require: false # currently 2.20 introduces a bug with '#falsey_literal?'
39+
gem 'rubocop-rails'
4040
gem 'rubocop-rake'
4141
gem 'rubocop-rspec'
4242
gem 'rubocop-rspec_rails'

Gemfile.lock

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
goggles_db (0.7.23)
4+
goggles_db (0.7.24)
55
acts-as-taggable-on
66
acts_as_votable
77
cities
@@ -118,7 +118,7 @@ GEM
118118
brakeman (6.2.2)
119119
racc
120120
builder (3.3.0)
121-
bullet (7.2.0)
121+
bullet (8.0.0)
122122
activesupport (>= 3.0.0)
123123
uniform_notifier (~> 1.11)
124124
byebug (11.1.3)
@@ -137,7 +137,7 @@ GEM
137137
country_select (10.0.0)
138138
countries (> 5.0, < 8.0)
139139
crass (1.0.6)
140-
date (3.3.4)
140+
date (3.4.0)
141141
debug_inspector (1.2.0)
142142
devise (4.9.4)
143143
bcrypt (~> 3.0)
@@ -162,20 +162,20 @@ GEM
162162
factory_bot_rails (6.4.4)
163163
factory_bot (~> 6.5)
164164
railties (>= 5.0.0)
165-
faraday (2.12.0)
166-
faraday-net_http (>= 2.0, < 3.4)
165+
faraday (2.12.1)
166+
faraday-net_http (>= 2.0, < 3.5)
167167
json
168168
logger
169-
faraday-net_http (3.3.0)
170-
net-http
169+
faraday-net_http (3.4.0)
170+
net-http (>= 0.5.0)
171171
ffaker (2.23.0)
172172
ffi (1.17.0-x86_64-linux-gnu)
173173
formatador (1.1.0)
174174
fuzzy-string-match (1.0.1)
175175
RubyInline (>= 3.8.6)
176176
globalid (1.2.1)
177177
activesupport (>= 6.1)
178-
guard (2.18.1)
178+
guard (2.19.0)
179179
formatador (>= 0.2.4)
180180
listen (>= 2.7, < 4.0)
181181
lumberjack (>= 1.0.12, < 2.0)
@@ -234,7 +234,7 @@ GEM
234234
sparkr (>= 0.2.0)
235235
term-ansicolor
236236
yard (~> 0.9.12)
237-
json (2.7.4)
237+
json (2.8.2)
238238
jwt (2.9.3)
239239
base64
240240
language_server-protocol (3.17.0.3)
@@ -268,9 +268,9 @@ GEM
268268
bigdecimal (~> 3.1)
269269
mysql2 (0.5.6)
270270
nenv (0.3.0)
271-
net-http (0.4.1)
271+
net-http (0.5.0)
272272
uri
273-
net-imap (0.5.0)
273+
net-imap (0.5.1)
274274
date
275275
net-protocol
276276
net-pop (0.1.2)
@@ -279,7 +279,7 @@ GEM
279279
timeout
280280
net-smtp (0.5.0)
281281
net-protocol
282-
nio4r (2.7.3)
282+
nio4r (2.7.4)
283283
nokogiri (1.16.7-x86_64-linux)
284284
racc (~> 1.4)
285285
notiffany (0.1.3)
@@ -307,7 +307,7 @@ GEM
307307
omniauth (~> 2.0)
308308
orm_adapter (0.5.0)
309309
parallel (1.26.3)
310-
parser (3.3.5.0)
310+
parser (3.3.6.0)
311311
ast (~> 2.4.1)
312312
racc
313313
plus_codes (0.2.1)
@@ -371,7 +371,7 @@ GEM
371371
responders (3.1.1)
372372
actionpack (>= 5.2)
373373
railties (>= 5.2)
374-
rouge (4.4.0)
374+
rouge (4.5.1)
375375
rspec (3.13.0)
376376
rspec-core (~> 3.13.0)
377377
rspec-expectations (~> 3.13.0)
@@ -398,7 +398,7 @@ GEM
398398
rspec_pacman_formatter (0.1.7)
399399
colorize
400400
rspec
401-
rubocop (1.67.0)
401+
rubocop (1.68.0)
402402
json (~> 2.3)
403403
language_server-protocol (>= 3.17.0)
404404
parallel (~> 1.10)
@@ -408,20 +408,21 @@ GEM
408408
rubocop-ast (>= 1.32.2, < 2.0)
409409
ruby-progressbar (~> 1.7)
410410
unicode-display_width (>= 2.4.0, < 3.0)
411-
rubocop-ast (1.32.3)
411+
rubocop-ast (1.36.1)
412412
parser (>= 3.3.1.0)
413413
rubocop-factory_bot (2.26.1)
414414
rubocop (~> 1.61)
415-
rubocop-performance (1.22.1)
415+
rubocop-performance (1.23.0)
416416
rubocop (>= 1.48.1, < 2.0)
417417
rubocop-ast (>= 1.31.1, < 2.0)
418-
rubocop-rails (2.19.0)
418+
rubocop-rails (2.27.0)
419419
activesupport (>= 4.2.0)
420420
rack (>= 1.1)
421-
rubocop (>= 1.33.0, < 2.0)
421+
rubocop (>= 1.52.0, < 2.0)
422+
rubocop-ast (>= 1.31.1, < 2.0)
422423
rubocop-rake (0.6.0)
423424
rubocop (~> 1.0)
424-
rubocop-rspec (3.1.0)
425+
rubocop-rspec (3.2.0)
425426
rubocop (~> 1.61)
426427
rubocop-rspec_rails (2.30.0)
427428
rubocop (~> 1.61)
@@ -476,7 +477,7 @@ GEM
476477
tins (~> 1.0)
477478
thor (1.3.2)
478479
tilt (2.4.0)
479-
timeout (0.4.1)
480+
timeout (0.4.2)
480481
tins (1.37.0)
481482
bigdecimal
482483
sync
@@ -485,7 +486,7 @@ GEM
485486
unaccent (0.4.0)
486487
unicode-display_width (2.6.0)
487488
uniform_notifier (1.16.0)
488-
uri (0.13.1)
489+
uri (1.0.2)
489490
version_gem (1.1.4)
490491
warden (1.2.9)
491492
rack (>= 2.0.9)
@@ -533,7 +534,7 @@ DEPENDENCIES
533534
rubocop
534535
rubocop-factory_bot
535536
rubocop-performance
536-
rubocop-rails (= 2.19)
537+
rubocop-rails
537538
rubocop-rake
538539
rubocop-rspec
539540
rubocop-rspec_rails

app/commands/goggles_db/cmd_clone_categories.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def call
3030
return unless internal_members_valid?
3131

3232
# @from_season.category_types.each do |category_type|
33-
GogglesDb::CategoryType.includes(:season).where(season_id: @from_season.id).each do |category_type|
33+
GogglesDb::CategoryType.includes(:season).where(season_id: @from_season.id).find_each do |category_type|
3434
GogglesDb::CategoryType.create!(
3535
reject_common_columns(category_type.attributes)
3636
.merge(season_id: @to_season.id)

app/models/concerns/timing_manageable.rb

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# = TimingManageable
77
#
8-
# - version: 7-0.5.21
8+
# - version: 7-0.7.24
99
# - author: Steve A.
1010
#
1111
# Concrete Interface for Timing helper methods (@see lib/wrappers/timing.rb).
@@ -38,6 +38,30 @@ module TimingManageable
3838
# end
3939
# end
4040
# ---8<---
41+
#-- ------------------------------------------------------------------------
42+
#++
43+
44+
# Returns +true+ if the timing associated with this result is positive.
45+
# If the includee responds (at least) also to #hundredths_from_start,
46+
# this will check all the <tt>XXX_from_start</tt> columns as well.
47+
def positive?
48+
base_timing_positive = minutes.positive? || seconds.positive? || hundredths.positive?
49+
return base_timing_positive unless respond_to?(:hundredths_from_start)
50+
51+
base_timing_positive || minutes_from_start.positive? || seconds_from_start.positive? || hundredths_from_start.positive?
52+
end
53+
54+
# Make sure only positive timings will be considered as "present":
55+
alias present? positive? # (new, old)
56+
57+
# Returns +true+ if the timing associated with this result is zero.
58+
# If the includee responds (at least) also to #hundredths_from_start,
59+
# this will check all the <tt>XXX_from_start</tt> columns as well.
60+
def zero?
61+
!positive?
62+
end
63+
#-- ------------------------------------------------------------------------
64+
#++
4165

4266
# Returns a new Timing instance initialized with the timing data from this row
4367
# (@see lib/wrappers/timing.rb)

app/models/goggles_db/abstract_lap.rb

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module GogglesDb
66
#
77
# Encapsulates common behavior for Laps & User Laps.
88
#
9-
# - version: 7-0.6.30
9+
# - version: 7-0.7.24
1010
# - author: Steve A.
1111
#
1212
class AbstractLap < ApplicationRecord
@@ -48,41 +48,6 @@ class AbstractLap < ApplicationRecord
4848
#-- -----------------------------------------------------------------------
4949
#++
5050

51-
# Returns the single lap row preceding this one by distance, if any; +nil+ otherwise.
52-
def previous_lap
53-
self.class.related_laps(self).where("#{self.class.table_name}.length_in_meters < ?", length_in_meters).last
54-
end
55-
56-
# ADD recompute_delta method using same strategy as in main
57-
58-
# Returns the Timing instance storing the lap timing from the start of the race.
59-
#
60-
# If the "_from_start" fields have not been filled in, this will try to recompute the
61-
# absolute timing using all deltas
62-
#
63-
# (Note that this will imply 3 summing queries and it may fail to yield correct values
64-
# if the preceding deltas are not set.)
65-
def timing_from_start
66-
# Quick way to detect if the timing from start is already set:
67-
amount = minutes_from_start.to_i + hundredths_from_start.to_i + seconds_from_start.to_i
68-
if amount.positive?
69-
Timing.new(
70-
hundredths: hundredths_from_start,
71-
seconds: seconds_from_start,
72-
minutes: minutes_from_start
73-
)
74-
else
75-
laps = self.class.summing_laps(self)
76-
Timing.new(
77-
hundredths: laps.sum(:hundredths),
78-
seconds: laps.sum(:seconds),
79-
minutes: laps.sum(:minutes)
80-
)
81-
end
82-
end
83-
#-- ------------------------------------------------------------------------
84-
#++
85-
8651
# Override: returns the list of single association names (as symbols)
8752
# included by <tt>#to_hash</tt> (and, consequently, by <tt>#to_json</tt>).
8853
#
@@ -94,8 +59,8 @@ def single_associations
9459
#
9560
def minimal_attributes(locale = I18n.locale)
9661
super.merge(
97-
'timing' => to_timing.to_s,
98-
'timing_from_start' => timing_from_start.to_s
62+
'timing' => to_timing.to_s, # (delta timing)
63+
'timing_from_start' => timing_from_start.to_s # (actual lap timing)
9964
)
10065
end
10166

@@ -129,6 +94,43 @@ def swimmer_attributes
12994
'year_guessed' => swimmer.year_guessed
13095
}
13196
end
97+
#-- ------------------------------------------------------------------------
98+
#++
99+
100+
# Returns the single lap row preceding this one by distance, if any; +nil+ otherwise.
101+
def previous_lap
102+
self.class.related_laps(self).where("#{self.class.table_name}.length_in_meters < ?", length_in_meters).last
103+
end
104+
105+
# ADD recompute_delta method using same strategy as in main
106+
107+
# Returns the Timing instance storing the lap timing from the start of the race.
108+
#
109+
# If the "_from_start" fields have not been filled in, this will try to recompute the
110+
# absolute timing using all deltas
111+
#
112+
# (Note that this will imply 3 summing queries and it may fail to yield correct values
113+
# if the preceding deltas are not set.)
114+
def timing_from_start
115+
# Quick way to detect if the timing from start is already set:
116+
lap_present = minutes_from_start.positive? || seconds_from_start.positive? || hundredths_from_start.positive?
117+
if lap_present
118+
Timing.new(
119+
hundredths: hundredths_from_start,
120+
seconds: seconds_from_start,
121+
minutes: minutes_from_start
122+
)
123+
else
124+
laps = self.class.summing_laps(self)
125+
Timing.new(
126+
hundredths: laps.sum(:hundredths),
127+
seconds: laps.sum(:seconds),
128+
minutes: laps.sum(:minutes)
129+
)
130+
end
131+
end
132+
#-- ------------------------------------------------------------------------
133+
#++
132134

133135
protected
134136

app/models/goggles_db/abstract_meeting.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module GogglesDb
66
#
77
# Encapsulates common behavior for Meetings & User Workshops.
88
#
9-
# - version: 7-0.5.10
9+
# - version: 7-0.7.24
1010
# - author: Steve A.
1111
#
1212
class AbstractMeeting < ApplicationRecord
@@ -35,7 +35,7 @@ class AbstractMeeting < ApplicationRecord
3535

3636
# Filtering scopes:
3737
scope :not_cancelled, -> { where(cancelled: false) }
38-
scope :not_expired, -> { not_cancelled.where('header_date >= ?', Time.zone.today) }
38+
scope :not_expired, -> { not_cancelled.where(header_date: Time.zone.today..) }
3939
scope :for_season_type, ->(season_type) { joins(:season_type).where(season_types: { id: season_type.id }) }
4040
scope :for_season, ->(season) { joins(:season).where(season_id: season.id) }
4141
scope :for_code, ->(code) { where(code:) }
@@ -95,16 +95,14 @@ def name_with_edition(meeting_name = description)
9595
# - <tt>meeting_name</tt>: the meeting name to be processed;
9696
# defaults to +description+.
9797
#
98-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
9998
def condensed_name(meeting_name = description)
10099
tokens = split_description_in_tokens(name_without_edition(meeting_name))
101100
# Fallback to using the notes if we have them and the splitting above does not yield tokens:
102101
tokens = split_description_in_tokens(notes) if tokens.blank? && notes.present?
103102
# Remove spaces, split in shorter tokens, delete blanks and take just the first 3:
104-
tokens = tokens&.to_s&.strip&.split(/\s|,/)&.reject(&:blank?)
103+
tokens = tokens.to_s.strip.split(/\s|,/).compact_blank if tokens.present?
105104
tokens.is_a?(Array) ? tokens[0..3]&.join(' ') : tokens.to_s
106105
end
107-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
108106
#++
109107

110108
# Returns +true+ if this abstract meeting has either been cancelled or closed for due time.

app/models/goggles_db/abstract_result.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ def swimmer_attributes
118118
'year_guessed' => swimmer&.year_guessed
119119
}
120120
end
121+
#-- ------------------------------------------------------------------------
122+
#++
121123

122124
protected
123125

0 commit comments

Comments
 (0)