Skip to content

Commit

Permalink
speed up FindByPath.find on K8s/RDS environments
Browse files Browse the repository at this point in the history
  • Loading branch information
aldavidson committed Oct 12, 2023
1 parent 6498f48 commit 7fab734
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/lib/find_by_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ def initialize(model_class)
def find(path)
exact_match = model_class.where(base_path: path).first
return exact_match if exact_match

Check failure on line 18 in app/lib/find_by_path.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/TrailingWhitespace: Trailing whitespace detected. (https://rubystyle.guide#no-trailing-whitespace)
matches = find_route_matches(path)
matches.any? ? best_route_match(matches, path) : nil

Check failure on line 20 in app/lib/find_by_path.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Layout/TrailingWhitespace: Trailing whitespace detected. (https://rubystyle.guide#no-trailing-whitespace)
if matches.count > 0

Check failure on line 21 in app/lib/find_by_path.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/NumericPredicate: Use `matches.count.positive?` instead of `matches.count > 0`. (https://rubystyle.guide#predicate-methods)
best_route_match(matches, path)
else

Check failure on line 23 in app/lib/find_by_path.rb

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/EmptyElse: Redundant `else`-clause.
nil
end
end

private
Expand Down

0 comments on commit 7fab734

Please sign in to comment.