X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;ds=sidebyside;f=a%2Fmc2015st.en;fp=a%2Fmc2015st.en;h=66bbd797524351338be1af20d66926c772d172d6;hb=d7ef1b104b14f7a07fedcfee5141d54b98e7b932;hp=0000000000000000000000000000000000000000;hpb=84899acc134472beb68d9ff03a4da0134b88e2e6;p=plack-app-gruntmaster.git diff --git a/a/mc2015st.en b/a/mc2015st.en new file mode 100644 index 0000000..66bbd79 --- /dev/null +++ b/a/mc2015st.en @@ -0,0 +1,427 @@ +
1 #!/usr/bin/perl + 2 use v5.14; + 3 use warnings; + 4 + 5 use Encode qw/encode/; + 6 use HTTP::Tiny; + 7 use JSON::PP qw/decode_json/; + 8 + 9 my %scores; + 10 my %user_to_name; + 11 + 12 my @contests = qw/mc2015r1 mc2015r2/; + 13 my $ht = HTTP::Tiny->new; + 14 + 15 for my $ct (@contests) { + 16 my $st = decode_json $ht->get("https://mindcoding.ro/st/$ct?format=json")->{content}; + 17 my @st = @{$st->{st}}; + 18 for (@st) { + 19 $scores{$_->{user}}{$ct} = $_->{score}; + 20 $scores{$_->{user}}{total} += $_->{score}; + 21 $user_to_name{$_->{user}} = $_->{user_name} // $_->{user}; + 22 } + 23 } + 24 + 25 print <<''; + 26 <table class="table table-bordered table-striped"> + 27 <thead> + 28 <tr><th>No.<th>User<th>Round 1<th>Round 2<th>Total + 29 <tbody> + 30 + 31 my $nr = 1; + 32 for my $user (sort {$scores{$b}{total} <=> $scores{$a}{total} or $a cmp $b} keys %scores) { + 33 my $cts = join '<td>', map { $scores{$user}{$_} // '-' } @contests; + 34 say encode 'UTF-8', qq,<tr><td>$nr<td><a href="/us/$user">$user_to_name{$user}</a><td>$cts<td>$scores{$user}{total},; + 35 $nr++; + 36 } + 37 + 38 say '</table>'; ++