From f35d7bd450ee4f79c2427d7e8751253eb5881470 Mon Sep 17 00:00:00 2001 From: Gregory Bartholomew Date: Jan 24 2022 19:16:27 +0000 Subject: Cache the FPCA signature status Closes #22 --- diff --git a/bot/commands/fas.pm b/bot/commands/fas.pm index 550fc27..076fbdb 100644 --- a/bot/commands/fas.pm +++ b/bot/commands/fas.pm @@ -35,6 +35,8 @@ my $hdr = { 'content-type' => undef, }; +my %cache; + # takes a FAS username and returns one of unknown, unsigned, or signed # depending on the user's 'Fedora Project Contributor Agreement' status sub fpca { @@ -42,6 +44,8 @@ sub fpca { return 'unknown' unless $user =~ m{^[[:word:]]+$}; + return $cache{$user} if $cache{$user}; + return 'unknown' unless $ath->{'cache_present'}; my $data = $api->get("/users/$user/agreements/", undef, $hdr); @@ -49,15 +53,15 @@ sub fpca { return 'unknown' unless $list; - my $fpca = 'unsigned'; + $cache{$user} = 'unsigned'; for (@$list) { if ($_->{'name'} eq 'Fedora Project Contributor Agreement') { - $fpca = 'signed'; + $cache{$user} = 'signed'; last; } } - return $fpca; + return $cache{$user}; } 1;