From: Jan "Yenya" Kasprzak Date: Fri, 3 Dec 2021 05:22:22 +0000 (+0100) Subject: leaderboard: -f to force-load the JSON data from server X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=d0e71407f04a51554cd1dab5facd3ab02ece9acc;hp=e5aab31ddde8e15c83f2d148b2a81818e1420ba4;p=aoc2021.git leaderboard: -f to force-load the JSON data from server --- diff --git a/leaderboard b/leaderboard index 7bc84c4..42874cd 100755 --- a/leaderboard +++ b/leaderboard @@ -11,18 +11,20 @@ my $board_id = 652041; my $my_name = 'Yenya'; my $day = (localtime(time))[3]; my $mode = 'r'; +my $force; getopt 'n|name=s' => \$my_name, 'd|day=i' => \$day, '1|first-task' => sub { $mode = '1' }, '2|second-task' => sub { $mode = '2' }, 'r|relative' => sub { $mode = 'r' }, - 'b|board=i' => \$board_id + 'b|board=i' => \$board_id, + 'f|force' => \$force or die "Usage: $0 [-n username] [-1|-2|-r] [-b board_id]\n"; my $cache_filename = "cache-$board_id.json"; my $cached = curfile->sibling($cache_filename); -if (!$cached->stat || time - $cached->stat->mtime > 900) { +if ($force || !$cached->stat || time - $cached->stat->mtime > 900) { warn "Downloading $cache_filename\n"; chomp(my $cookie = curfile->sibling('cookie')->slurp); my $res = Mojo::UserAgent->new->get(