]> www.fi.muni.cz Git - aoc.git/commitdiff
leaderboard: separate cache for each leaderboard
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 2 Dec 2021 08:36:27 +0000 (09:36 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 2 Dec 2021 08:36:27 +0000 (09:36 +0100)
leaderboard

index cc2ed5b7cd5c04df71ee6f01e1fd28f8d7417dfe..7bc84c4ee10ec246b11f427c1006b5ff62923ab6 100755 (executable)
@@ -11,7 +11,6 @@ my $board_id = 652041;
 my $my_name = 'Yenya';
 my $day = (localtime(time))[3];
 my $mode = 'r';
-my $cached = curfile->sibling('cache.json');
 getopt
        'n|name=s'      => \$my_name,
        'd|day=i'       => \$day,
@@ -20,9 +19,11 @@ getopt
        'r|relative'    => sub { $mode = 'r' },
        'b|board=i'     => \$board_id
 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) {
-       warn "Downloading cache.json\n";
+       warn "Downloading $cache_filename\n";
        chomp(my $cookie = curfile->sibling('cookie')->slurp);
        my $res = Mojo::UserAgent->new->get(
                "https://adventofcode.com/2021/leaderboard/private/view/$board_id.json",