jumbotron 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/adapters/jumbotron/adapters/espn/nfl_helpers/scoreboard.rb +1 -0
- data/app/adapters/jumbotron/adapters/espn/nfl_helpers/team_nickname.rb +19 -0
- data/app/adapters/jumbotron/adapters/espn/nfl_helpers/teams.rb +2 -1
- data/app/deserializers/jumbotron/deserializers/clients/espn/team.rb +2 -0
- data/app/models/jumbotron/canonical.rb +12 -3
- data/app/models/jumbotron/public.rb +5 -1
- data/app/models/jumbotron/team.rb +11 -0
- data/app/services/jumbotron/services/canonical/upsert_game_participant.rb +2 -1
- data/app/services/jumbotron/services/canonical/upsert_team.rb +40 -0
- data/app/services/jumbotron/services/public/assemble_public_game.rb +6 -1
- data/db/migrate/20260827150001_add_key_to_jumbotron_teams.rb +49 -0
- data/db/migrate/20260828180001_add_nickname_to_jumbotron_teams.rb +7 -0
- data/lib/jumbotron/team_key.rb +22 -0
- data/lib/jumbotron/version.rb +1 -1
- data/lib/jumbotron.rb +1 -0
- data/spec/factories/jumbotron/team.rb +6 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02e887f5ad4260dddda6dde8d391430ffbad31b7b7069dd851e9560cd6f92540
|
|
4
|
+
data.tar.gz: 1a18545151d81f504bc9bf208316ff2b1cf68086f062cf590d0953f9ca28e546
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c20c23af5c011df7a9ea866a1923e37abf79b3eea2dfe82e47b561051f3ba6bc43dfb519def7288007e71c7a801020e9d5b32f3d2a76be82c6b85061c2f9bbe1
|
|
7
|
+
data.tar.gz: 5414a02d268f32a257752bc29e47b959c46a0dc9b6d680da58c789ff22bd6d76a56a4c264a0068bc32f91aef79a40827b4568a731807dedfcf975966a452d63c
|
|
@@ -103,6 +103,7 @@ module Jumbotron
|
|
|
103
103
|
Canonical::ProviderIdentityRef.new(provider: "espn", namespace: "team", id: team.id.to_s)
|
|
104
104
|
],
|
|
105
105
|
team_name: name.to_s,
|
|
106
|
+
team_nickname: TeamNickname.resolve(team),
|
|
106
107
|
role: competitor.home_away.to_s,
|
|
107
108
|
score: coerce_score(competitor.score),
|
|
108
109
|
result: coerce_result(competitor.winner, lifecycle)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jumbotron
|
|
4
|
+
module Adapters
|
|
5
|
+
module Espn
|
|
6
|
+
module NflHelpers
|
|
7
|
+
# Maps ESPN team identity fields into canonical nickname without parsing display_name.
|
|
8
|
+
# Precedence: nickname → name → short_display_name (provider fields only).
|
|
9
|
+
module TeamNickname
|
|
10
|
+
def self.resolve(team)
|
|
11
|
+
return nil if team.nil?
|
|
12
|
+
|
|
13
|
+
team.nickname.presence || team.name.presence || team.short_display_name.presence
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -24,7 +24,8 @@ module Jumbotron
|
|
|
24
24
|
provider_identities: [
|
|
25
25
|
Canonical::ProviderIdentityRef.new(provider: "espn", namespace: "team", id: team.id.to_s)
|
|
26
26
|
],
|
|
27
|
-
name: name.to_s
|
|
27
|
+
name: name.to_s,
|
|
28
|
+
nickname: TeamNickname.resolve(team)
|
|
28
29
|
)
|
|
29
30
|
end
|
|
30
31
|
private_class_method :transform_team
|
|
@@ -12,6 +12,7 @@ module Jumbotron
|
|
|
12
12
|
field :display_name, type: Support.types.string, required: true
|
|
13
13
|
field :short_display_name, type: Support.types.string, nullable: true
|
|
14
14
|
field :name, type: Support.types.string, nullable: true
|
|
15
|
+
field :nickname, type: Support.types.string, nullable: true
|
|
15
16
|
field :location, type: Support.types.string, nullable: true
|
|
16
17
|
end
|
|
17
18
|
|
|
@@ -25,6 +26,7 @@ module Jumbotron
|
|
|
25
26
|
display_name: Support.payload.fetch(payload, "displayName"),
|
|
26
27
|
short_display_name: Support.payload.fetch(payload, "shortDisplayName"),
|
|
27
28
|
name: Support.payload.fetch(payload, "name"),
|
|
29
|
+
nickname: Support.payload.fetch(payload, "nickname"),
|
|
28
30
|
location: Support.payload.fetch(payload, "location")
|
|
29
31
|
)
|
|
30
32
|
end
|
|
@@ -4,7 +4,11 @@ module Jumbotron
|
|
|
4
4
|
module Canonical
|
|
5
5
|
ProviderIdentityRef = Data.define(:provider, :namespace, :id)
|
|
6
6
|
|
|
7
|
-
TeamInput = Data.define(:provider_identities, :name)
|
|
7
|
+
TeamInput = Data.define(:provider_identities, :name, :nickname) do
|
|
8
|
+
def initialize(provider_identities:, name:, nickname: nil)
|
|
9
|
+
super
|
|
10
|
+
end
|
|
11
|
+
end
|
|
8
12
|
|
|
9
13
|
VenueInput = Data.define(:provider_identities, :name)
|
|
10
14
|
|
|
@@ -13,8 +17,13 @@ module Jumbotron
|
|
|
13
17
|
:team_name,
|
|
14
18
|
:role,
|
|
15
19
|
:score,
|
|
16
|
-
:result
|
|
17
|
-
|
|
20
|
+
:result,
|
|
21
|
+
:team_nickname
|
|
22
|
+
) do
|
|
23
|
+
def initialize(provider_identities:, team_name:, role:, score:, result:, team_nickname: nil)
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
end
|
|
18
27
|
|
|
19
28
|
ScheduleGroupInput = Data.define(:kind, :number, :name)
|
|
20
29
|
|
|
@@ -19,7 +19,11 @@ module Jumbotron
|
|
|
19
19
|
:season_phase,
|
|
20
20
|
:kind
|
|
21
21
|
)
|
|
22
|
-
Team = Data.define(:id, :name)
|
|
22
|
+
Team = Data.define(:id, :name, :nickname, :key) do
|
|
23
|
+
def initialize(id:, name:, key:, nickname: nil)
|
|
24
|
+
super(id:, name:, nickname:, key:)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
23
27
|
Venue = Data.define(:id, :name)
|
|
24
28
|
Participant = Data.define(:role, :score, :result, :team)
|
|
25
29
|
GameSegment = Data.define(:kind, :number)
|
|
@@ -7,5 +7,16 @@ module Jumbotron
|
|
|
7
7
|
has_many :provider_identities, as: :target, inverse_of: :target, dependent: :restrict_with_exception
|
|
8
8
|
|
|
9
9
|
validates :name, presence: true
|
|
10
|
+
validates :key, presence: true, uniqueness: true
|
|
11
|
+
validate :key_format_must_be_semantic
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def key_format_must_be_semantic
|
|
16
|
+
return if key.blank?
|
|
17
|
+
return if Jumbotron::TeamKey.valid_format?(key)
|
|
18
|
+
|
|
19
|
+
errors.add(:key, "must be a lowercase kebab-case semantic key")
|
|
20
|
+
end
|
|
10
21
|
end
|
|
11
22
|
end
|
|
@@ -13,7 +13,8 @@ module Jumbotron
|
|
|
13
13
|
team_result = UpsertTeam.call(
|
|
14
14
|
team_input: Jumbotron::Canonical::TeamInput.new(
|
|
15
15
|
provider_identities: participant_input.provider_identities,
|
|
16
|
-
name: participant_input.team_name
|
|
16
|
+
name: participant_input.team_name,
|
|
17
|
+
nickname: participant_input.team_nickname
|
|
17
18
|
),
|
|
18
19
|
observed_at: observed_at,
|
|
19
20
|
change_set: change_set
|
|
@@ -57,6 +57,8 @@ module Jumbotron
|
|
|
57
57
|
team.name = team_input.name
|
|
58
58
|
team.changed_at = observed_at
|
|
59
59
|
end
|
|
60
|
+
apply_nickname!(team)
|
|
61
|
+
# key is immutable after assignment — never regenerate from name or provider id
|
|
60
62
|
team.observed_at = observed_at
|
|
61
63
|
team.save!
|
|
62
64
|
team
|
|
@@ -65,13 +67,51 @@ module Jumbotron
|
|
|
65
67
|
def create_new!
|
|
66
68
|
team = Team.create!(
|
|
67
69
|
name: team_input.name,
|
|
70
|
+
nickname: team_input.nickname,
|
|
71
|
+
key: allocate_key!(team_input.name),
|
|
68
72
|
observed_at: observed_at,
|
|
69
73
|
changed_at: observed_at
|
|
70
74
|
)
|
|
71
75
|
change_set.record(subject: team, attribute: "name", previous: nil, new_value: team.name)
|
|
76
|
+
change_set.record(subject: team, attribute: "key", previous: nil, new_value: team.key)
|
|
77
|
+
if team.nickname.present?
|
|
78
|
+
change_set.record(
|
|
79
|
+
subject: team,
|
|
80
|
+
attribute: "nickname",
|
|
81
|
+
previous: nil,
|
|
82
|
+
new_value: team.nickname
|
|
83
|
+
)
|
|
84
|
+
end
|
|
72
85
|
team
|
|
73
86
|
end
|
|
74
87
|
|
|
88
|
+
def apply_nickname!(team)
|
|
89
|
+
return if team_input.nickname.nil?
|
|
90
|
+
return if team.nickname == team_input.nickname
|
|
91
|
+
|
|
92
|
+
change_set.record(
|
|
93
|
+
subject: team,
|
|
94
|
+
attribute: "nickname",
|
|
95
|
+
previous: team.nickname,
|
|
96
|
+
new_value: team_input.nickname
|
|
97
|
+
)
|
|
98
|
+
team.nickname = team_input.nickname
|
|
99
|
+
team.changed_at = observed_at
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def allocate_key!(name)
|
|
103
|
+
base = Jumbotron::TeamKey.normalize(name)
|
|
104
|
+
return base unless Team.exists?(key: base)
|
|
105
|
+
|
|
106
|
+
suffix = 2
|
|
107
|
+
loop do
|
|
108
|
+
candidate = "#{base}-#{suffix}"
|
|
109
|
+
return candidate unless Team.exists?(key: candidate)
|
|
110
|
+
|
|
111
|
+
suffix += 1
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
75
115
|
def recover_after_race!
|
|
76
116
|
ref = team_input.provider_identities.first
|
|
77
117
|
identity = ProviderIdentity.find_by!(
|
|
@@ -69,7 +69,12 @@ module Jumbotron
|
|
|
69
69
|
role: participant.role,
|
|
70
70
|
score: participant.score,
|
|
71
71
|
result: participant.result,
|
|
72
|
-
team: Jumbotron::Public::Team.new(
|
|
72
|
+
team: Jumbotron::Public::Team.new(
|
|
73
|
+
id: participant.team.id,
|
|
74
|
+
name: participant.team.name,
|
|
75
|
+
nickname: participant.team.nickname,
|
|
76
|
+
key: participant.team.key
|
|
77
|
+
)
|
|
73
78
|
)
|
|
74
79
|
end
|
|
75
80
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddKeyToJumbotronTeams < ActiveRecord::Migration[8.1]
|
|
4
|
+
def up
|
|
5
|
+
add_column :jumbotron_teams, :key, :string, limit: 191
|
|
6
|
+
backfill_keys!
|
|
7
|
+
change_column_null :jumbotron_teams, :key, false
|
|
8
|
+
add_index :jumbotron_teams, :key, unique: true, name: "index_jumbotron_teams_on_key"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def down
|
|
12
|
+
remove_index :jumbotron_teams, name: "index_jumbotron_teams_on_key"
|
|
13
|
+
remove_column :jumbotron_teams, :key
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def backfill_keys!
|
|
19
|
+
say_with_time "backfill jumbotron_teams.key" do
|
|
20
|
+
taken = {}
|
|
21
|
+
connection.select_all("SELECT id, name FROM jumbotron_teams ORDER BY id").each do |row|
|
|
22
|
+
key = allocate_key(normalize_name(row["name"]), taken)
|
|
23
|
+
taken[key] = true
|
|
24
|
+
connection.execute(
|
|
25
|
+
"UPDATE jumbotron_teams SET `key` = #{connection.quote(key)} WHERE id = #{row['id'].to_i}"
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def normalize_name(name)
|
|
32
|
+
slug = name.to_s.unicode_normalize(:nfc).downcase
|
|
33
|
+
slug = slug.gsub(/[^a-z0-9]+/, "-").gsub(/\A-+|-+\z/, "")
|
|
34
|
+
slug = "team" if slug.blank?
|
|
35
|
+
slug
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def allocate_key(base, taken)
|
|
39
|
+
return base unless taken[base]
|
|
40
|
+
|
|
41
|
+
suffix = 2
|
|
42
|
+
loop do
|
|
43
|
+
candidate = "#{base}-#{suffix}"
|
|
44
|
+
return candidate unless taken[candidate]
|
|
45
|
+
|
|
46
|
+
suffix += 1
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jumbotron
|
|
4
|
+
# Immutable semantic public team identity helper.
|
|
5
|
+
# Derives a kebab-case slug once at assignment; callers must not re-run on rename.
|
|
6
|
+
module TeamKey
|
|
7
|
+
FORMAT = /\A[a-z0-9]+(?:-[a-z0-9]+)*\z/
|
|
8
|
+
|
|
9
|
+
module_function
|
|
10
|
+
|
|
11
|
+
def normalize(name)
|
|
12
|
+
slug = name.to_s.unicode_normalize(:nfc).downcase
|
|
13
|
+
slug = slug.gsub(/[^a-z0-9]+/, "-").gsub(/\A-+|-+\z/, "")
|
|
14
|
+
slug = "team" if slug.blank?
|
|
15
|
+
slug
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def valid_format?(key)
|
|
19
|
+
key.to_s.match?(FORMAT)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/jumbotron/version.rb
CHANGED
data/lib/jumbotron.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jumbotron
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- matt-taylor
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: command_tower
|
|
@@ -65,6 +65,7 @@ files:
|
|
|
65
65
|
- app/adapters/jumbotron/adapters/espn/nfl_helpers/progress.rb
|
|
66
66
|
- app/adapters/jumbotron/adapters/espn/nfl_helpers/scoreboard.rb
|
|
67
67
|
- app/adapters/jumbotron/adapters/espn/nfl_helpers/season_phase.rb
|
|
68
|
+
- app/adapters/jumbotron/adapters/espn/nfl_helpers/team_nickname.rb
|
|
68
69
|
- app/adapters/jumbotron/adapters/espn/nfl_helpers/teams.rb
|
|
69
70
|
- app/adapters/jumbotron/adapters/line_acquisition.rb
|
|
70
71
|
- app/adapters/jumbotron/adapters/operation.rb
|
|
@@ -205,6 +206,8 @@ files:
|
|
|
205
206
|
- db/migrate/20260813000001_create_jumbotron_schedule_groups.rb
|
|
206
207
|
- db/migrate/20260814000001_create_jumbotron_line_observations.rb
|
|
207
208
|
- db/migrate/20260820000001_add_progress_to_jumbotron_games.rb
|
|
209
|
+
- db/migrate/20260827150001_add_key_to_jumbotron_teams.rb
|
|
210
|
+
- db/migrate/20260828180001_add_nickname_to_jumbotron_teams.rb
|
|
208
211
|
- docs/testing.md
|
|
209
212
|
- docs/upgrades/0.1.2.md
|
|
210
213
|
- docs/upgrades/0.1.3.md
|
|
@@ -212,6 +215,7 @@ files:
|
|
|
212
215
|
- lib/jumbotron.rb
|
|
213
216
|
- lib/jumbotron/client.rb
|
|
214
217
|
- lib/jumbotron/engine.rb
|
|
218
|
+
- lib/jumbotron/team_key.rb
|
|
215
219
|
- lib/jumbotron/testing.rb
|
|
216
220
|
- lib/jumbotron/version.rb
|
|
217
221
|
- lib/tasks/jumbotron_schedules.rake
|