Various improvements to script

I wrot ethese a while ago.
This commit is contained in:
Bradley M. Kuhn 2019-12-10 09:40:06 -08:00
parent 8f6bd0e563
commit a1b7dc5458

View file

@ -21,7 +21,7 @@ my @typeList = qw/t-shirt-0 t-shirt-1 t-shirt-extra-0 t-shirt-fy2018design-0/;
my %requests = ( soon => {}, now => {} ); my %requests = ( soon => {}, now => {} );
%{$requests{now}} = map { ($_, {}) } @typeList; %{$requests{now}} = map { ($_, {}) } @typeList;
%{$requests{soon}} = map { ($_, {}) } @typeList; %{$requests{soon}} = map { ($_, {}) } @typeList;
my %monthCounts = map { ($_, {}) } @typeList;
my($SUPPORTERS_SQLITE_DB_FILE, $GIVING_LIMIT, $MONTHLY_SEARCH_REGEX, $ANNUAL_SEARCH_REGEX,, @LEDGER_CMD_LINE) = @ARGV; my($SUPPORTERS_SQLITE_DB_FILE, $GIVING_LIMIT, $MONTHLY_SEARCH_REGEX, $ANNUAL_SEARCH_REGEX,, @LEDGER_CMD_LINE) = @ARGV;
@ -40,6 +40,12 @@ foreach my $id (sort { $a <=> $b } @supporterIds) {
$sizeNeeded = $request->{requestConfiguration}; $sizeNeeded = $request->{requestConfiguration};
my $amount = $sp->donorTotalGaveInPeriod(donorId => $id); my $amount = $sp->donorTotalGaveInPeriod(donorId => $id);
my $when = ($amount < $GIVING_LIMIT) ? "soon" : "now"; my $when = ($amount < $GIVING_LIMIT) ? "soon" : "now";
if ($when eq 'now') {
my $month = $request->{requestDate};
$month =~ s/-\d{2,2}$//;
$monthCounts{$type}{$month} = 0 if not defined $monthCounts{$type}{$month};
$monthCounts{$type}{$month}++;
}
$requests{$when}{$type}{$sizeNeeded} = 0 unless defined $requests{$when}{$type}{$sizeNeeded}; $requests{$when}{$type}{$sizeNeeded} = 0 unless defined $requests{$when}{$type}{$sizeNeeded};
$requests{$when}{$type}{$sizeNeeded}++; $requests{$when}{$type}{$sizeNeeded}++;
print STDERR "t-shirt-1 in $sizeNeeded wanted $when by $id\n" if ($type eq 't-shirt-1'); print STDERR "t-shirt-1 in $sizeNeeded wanted $when by $id\n" if ($type eq 't-shirt-1');
@ -58,6 +64,14 @@ foreach my $key ('now', 'soon') {
} }
} }
} }
print "\n\nWAITING AMOUNT SINCE FOR THOSE WHO ARE READY NOW\n";
foreach my $type (sort {$a cmp $b } keys %monthCounts) {
print " $type: \n" if scalar(keys %{$monthCounts{$type}}) > 0;
foreach my $month (sort {$a cmp $b } keys %{$monthCounts{$type}}) {
print " $month: $monthCounts{$type}{$month}\n";
}
}
############################################################################### ###############################################################################
# #
# Local variables: # Local variables: