Merge pull request 'Issue #4: Improved formatting of constructor and driver standings.' (#7) from issue-4-formatting into master

This commit is contained in:
Stefan Härter 2023-07-16 17:22:12 +02:00 committed by Gitea
parent d39a2f15e2
commit a37f0bd317

View File

@ -193,13 +193,13 @@ sub statistics {
{} {}
); );
my %DriverStandings; my %DriverStandings;
my $DriverStandingsFormatted = sprintf( "%-3s%-4s%-5s%7s\n", my $DriverStandingsFormatted = sprintf( "%2s %3s %-5s%7s\n",
"#", "No.", "Code", "Points" ); "#", "No.", "Code", "Points" );
for my $Driver ( $Standings->{MRData}->{StandingsTable} for my $Driver ( $Standings->{MRData}->{StandingsTable}
->{StandingsLists}->[0]->{DriverStandings}->@* ) ->{StandingsLists}->[0]->{DriverStandings}->@* )
{ {
$DriverStandingsFormatted .= sprintf( $DriverStandingsFormatted .= sprintf(
"%-3d%-4d%-5s%7d\n", "%2d %3d %-5s%7d\n",
$Driver->{positionText}, $Driver->{positionText},
$Driver->{Driver}->{permanentNumber}, $Driver->{Driver}->{permanentNumber},
$Driver->{Driver}->{code}, $Driver->{Driver}->{code},
@ -248,17 +248,22 @@ sub statistics {
$Self->{LogObject} $Self->{LogObject}
->info( 'statistics: Fetched standings are ' ->info( 'statistics: Fetched standings are '
. Dumper($Standings) ); . Dumper($Standings) );
my %ConstructorStandings; my $ConstructorStandingsFormatted = sprintf( "%2s %-15s%7s\n",
my $ConstructorStandingsFormatted = ''; "#", "Name", "Points" );
for my $Constructor ( $Standings->{MRData}->{StandingsTable} for my $Constructor ( $Standings->{MRData}->{StandingsTable}
->{StandingsLists}->[0]->{ConstructorStandings}->@* ) ->{StandingsLists}->[0]->{ConstructorStandings}->@* )
{ {
$ConstructorStandingsFormatted .= $ConstructorStandingsFormatted .= sprintf(
"Position: $Constructor->{positionText}, Name: $Constructor->{Constructor}->{name} - Points: $Constructor->{points}\n"; "%2d %-15s%7d\n",
$Constructor->{positionText},
$Constructor->{Constructor}->{name},
$Constructor->{points}
);
} }
$ConstructorStandingsFormatted =~ s/^/<pre>/; $ConstructorStandingsFormatted =~ s/^/<pre>/;
$ConstructorStandingsFormatted =~ s/$/<\/pre>/; $ConstructorStandingsFormatted =~ s/$/<\/pre>/;
$ReturnData{text} = $ConstructorStandingsFormatted; $ReturnData{text} = $ConstructorStandingsFormatted;
$ReturnData{parse_mode} = 'HTML';
} }
default { default {
$ReturnData{text} = $ReturnData{text} =