From c6bcce6f3aa6a3e8af46c9c1d5c117177ac9c1b8 Mon Sep 17 00:00:00 2001 From: Ricardo Signes Date: Tue, 11 Jan 2022 15:41:04 -0500 Subject: [PATCH] Linear: rejigger team alias config This makes it easier to use the aliases to know a complete list of canonical names. --- lib/Synergy/Reactor/Linear.pm | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/Synergy/Reactor/Linear.pm b/lib/Synergy/Reactor/Linear.pm index 2849a278..2c9269a3 100644 --- a/lib/Synergy/Reactor/Linear.pm +++ b/lib/Synergy/Reactor/Linear.pm @@ -171,11 +171,36 @@ package Synergy::Reactor::Linear::LinearHelper { } has team_aliases => ( - traits => [ 'Hash' ], + reader => '_team_aliases', default => sub { {} }, + traits => [ 'Hash' ], handles => { + known_team_names => 'keys', + } +); + +has _name_mappings => ( + init_arg => undef, + lazy => 1, + traits => [ 'Hash' ], + handles => { canonical_team_name_for => 'get', }, + default => sub ($self) { + my $names = $self->_team_aliases; + + my %mapping; + for my $team (keys %$names) { + for ($team, $names->{$team}->@*) { + Carp::confess("Attempted to give two names for $_") + if exists $mapping{$_}; + + $mapping{$_} = $team; + } + } + + return \%mapping; + } ); has _linear_shared_cache => (