Skip to content

Commit

Permalink
fixes & refactorings for AbstractLap; amend upgrade to Rubocop 2.20 w…
Browse files Browse the repository at this point in the history
…hich is currently having issues
  • Loading branch information
steveoro committed Jun 18, 2023
1 parent 2b9858b commit 95348ff
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

_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_

- **0.5.22** [Steve A.] fixes & refactorings for AbstractLap; amend upgrade to Rubocop 2.20 which is currently having issues
- **0.5.21** [Steve A.] fixes for TimingManageable & Timing; bundle update
- **0.5.20** [Steve A.] re-added timestamps to #minimal_attributes output; added issue type #5; bundle update
- **0.5.12** [Steve A.] added LastSeasonId view; DB vers. 2.00.0
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ group :development do
gem 'listen', '~> 3.2'
gem 'rubocop'
gem 'rubocop-performance'
gem 'rubocop-rails', require: false
gem 'rubocop-rails', '= 2.19', require: false # currently 2.20 introduces a bug with '#falsey_literal?'
gem 'rubocop-rake'
gem 'rubocop-rspec'
gem 'spring'
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
goggles_db (0.5.21)
goggles_db (0.5.22)
acts-as-taggable-on
acts_as_votable
cities
Expand Down Expand Up @@ -397,7 +397,7 @@ GEM
rubocop-performance (1.18.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.20.0)
rubocop-rails (2.19.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
Expand Down Expand Up @@ -512,7 +512,7 @@ DEPENDENCIES
rspec_pacman_formatter
rubocop
rubocop-performance
rubocop-rails
rubocop-rails (= 2.19)
rubocop-rake
rubocop-rspec
scenic
Expand Down
16 changes: 9 additions & 7 deletions app/models/goggles_db/abstract_lap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module GogglesDb
#
# Encapsulates common behavior for Laps & User Laps.
#
# - version: 7-0.5.10
# - version: 7-0.5.21
# - author: Steve A.
#
class AbstractLap < ApplicationRecord
Expand Down Expand Up @@ -36,19 +36,21 @@ class AbstractLap < ApplicationRecord
scope :with_no_time, -> { where(minutes: 0, seconds: 0, hundredths: 0) }

# All siblings laps:
scope :related_laps, ->(lap) { by_distance.where(lap.parent_result_where_condition) }
scope :related_laps, lambda { |lap|
includes(parent_association_sym, :swimmer, :event_type)
.where(lap.parent_result_where_condition)
.by_distance
}
# All preceeding laps, including the current one:
scope :summing_laps, ->(lap) { related_laps(lap).where('length_in_meters <= ?', lap.length_in_meters) }
scope :summing_laps, ->(lap) { related_laps(lap).where("#{lap.class.table_name}.length_in_meters <= ?", lap.length_in_meters) }
# Just the laps following the specified one:
scope :following_laps, ->(lap) { related_laps(lap).where('length_in_meters > ?', lap.length_in_meters) }
scope :following_laps, ->(lap) { related_laps(lap).where("#{lap.class.table_name}.length_in_meters > ?", lap.length_in_meters) }
#-- -----------------------------------------------------------------------
#++

# XXX TODO: SPEC this one:

# Returns the single lap row preceeding this one by distance, if any; +nil+ otherwise.
def previous_lap
self.class.related_laps(self).where('length_in_meters < ?', length_in_meters).last
self.class.related_laps(self).where("#{self.class.table_name}.length_in_meters < ?", length_in_meters).last
end

# ADD recompute_delta method using same strategy as in main
Expand Down
6 changes: 3 additions & 3 deletions lib/goggles_db/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#
# = Version module
#
# - version: 7-0.5.21
# - version: 7-0.5.22
# - author: Steve A.
#
module GogglesDb
# Public gem version (uses Semantic versioning)
VERSION = '0.5.21'
VERSION = '0.5.22'

# == Versioning codes
#
Expand All @@ -21,7 +21,7 @@ module Version
CORE = 'C7'
MAJOR = '0'
MINOR = '5'
PATCH = '21'
PATCH = '22'
BUILD = '20230618'

# Full label
Expand Down

0 comments on commit 95348ff

Please sign in to comment.