Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ GEM
racc (~> 1.4)
ostruct (0.6.3)
parallel (2.1.0)
parser (3.3.11.1)
parser (3.3.12.0)
ast (~> 2.4.1)
racc
pp (0.6.4)
Expand Down Expand Up @@ -273,7 +273,7 @@ GEM
reline (0.6.3)
io-console (~> 0.5)
rexml (3.4.4)
rubocop (1.87.0)
rubocop (1.88.2)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
Expand Down Expand Up @@ -312,10 +312,10 @@ GEM
sidekiq-scheduler (6.0.2)
rufus-scheduler (~> 3.2)
sidekiq (>= 7.3, < 9)
standard (1.55.0)
standard (1.56.0)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.87.0)
rubocop (~> 1.88.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.8)
standard-custom (1.0.2)
Expand Down
2 changes: 1 addition & 1 deletion app/services/nhl/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_json(path)
response.parsed_response
rescue JSON::ParserError => e
raise RequestError, "Invalid JSON fetching #{path}: #{e.class} - #{e.message}"
rescue Net::OpenTimeout, Net::ReadTimeout, Timeout::Error, SocketError,
rescue Timeout::Error, SocketError,
Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError => e
raise RequestError, "Network error fetching #{path}: #{e.class} - #{e.message}"
end
Expand Down
4 changes: 1 addition & 3 deletions app/services/nhl/edge_client.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Nhl
class EdgeClient < Client

base_uri "https://api-web.nhle.com/v1"

ENDPOINTS = {
Expand All @@ -17,12 +16,11 @@ class EdgeClient < Client
class << self
ENDPOINTS.each do |name, (path, ttl)|
define_method("fetch_#{name}") do |subject_id, season: nil, game_type: nil|
period = season && game_type ? "#{season}/#{game_type}" : "now"
period = (season && game_type) ? "#{season}/#{game_type}" : "now"
cache_key = "edge_#{name}_#{subject_id}_#{period.tr("/", "_")}"
Rails.cache.fetch(cache_key, expires_in: ttl) { get_json("/edge/#{path}/#{subject_id}/#{period}") }
end
end

end
end
end
1 change: 0 additions & 1 deletion app/services/nhl/game_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def landing(game_id)
def right_rail(game_id)
get_json("/gamecenter/#{game_id}/right-rail")
end

end
end
end
2 changes: 1 addition & 1 deletion app/services/nhl/game_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def opponent_team_id(game_id, team_id: ENV.fetch("NHL_TEAM_ID").to_i)
away_id = feed&.dig("awayTeam", "id")
return unless home_id && away_id

home_id.to_i == team_id ? away_id.to_i : home_id.to_i
(home_id.to_i == team_id) ? away_id.to_i : home_id.to_i
end

private
Expand Down
1 change: 0 additions & 1 deletion app/services/nhl/player_directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,5 @@ def sweater_number(player_id)
def each(&block)
@identities.each_value(&block)
end

end
end
2 changes: 0 additions & 2 deletions app/services/nhl/season_calendar.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Nhl
class SeasonCalendar < Client

base_uri "https://api-web.nhle.com/v1"

class << self
Expand Down Expand Up @@ -32,7 +31,6 @@ def schedule
def local_today
Time.use_zone(ENV.fetch("TIME_ZONE")) { Time.zone.today }
end

end
end
end
4 changes: 2 additions & 2 deletions app/services/rod_the_bot/draft_pick/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def details(pick, ranking, position)
lines << "Ranking: #{ranking["finalRank"].ordinalize} in #{category}" if ranking["finalRank"] && category
lines << height_line(ranking["heightInInches"])
lines << weight_line(ranking["weightInPounds"])
lines << "#{position == "G" ? "Catches" : "Shoots"}: #{ranking["shootsCatches"]}" if ranking["shootsCatches"]
lines << "#{(position == "G") ? "Catches" : "Shoots"}: #{ranking["shootsCatches"]}" if ranking["shootsCatches"]
lines << "Birthday: #{Date.parse(ranking["birthDate"]).strftime("%m/%d/%Y")}" if ranking["birthDate"]
lines << "Birthplace: #{birthplace(ranking)}" if birthplace(ranking).present?
lines.compact.join("\n")
Expand All @@ -60,7 +60,7 @@ def birthplace(ranking)
province = ranking["birthStateProvince"]
country = ranking["birthCountry"]
return "#{city}, #{province}" if province.present?
city.present? && country.present? ? "#{city}, #{COUNTRIES[country] || country}" : city
(city.present? && country.present?) ? "#{city}, #{COUNTRIES[country] || country}" : city
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/rod_the_bot/edge_replay/post_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class PostFormatter
def format(play, players, feed)
scorer_id = play.dig("details", "scoringPlayerId")
scorer = scorer_id ? players.name_with_number(scorer_id) : "Unknown Player"
scoring_team = feed[feed.dig("homeTeam", "id") == play.dig("details", "eventOwnerTeamId") ? "homeTeam" : "awayTeam"]["abbrev"]
scoring_team = feed[(feed.dig("homeTeam", "id") == play.dig("details", "eventOwnerTeamId")) ? "homeTeam" : "awayTeam"]["abbrev"]
period = format_period_name(play.dig("periodDescriptor", "number"))

assists = %w[assist1PlayerId assist2PlayerId].filter_map do |key|
Expand Down
Loading