count old interns.

This commit is contained in:
Bradley M. Kuhn 2018-07-22 15:31:18 -07:00
parent 467522f331
commit ace578089c

View file

@ -149,6 +149,8 @@ $VERBOSE = 0 unless defined $VERBOSE;
opendir(my $dh, $PAYMENT_DIR);
my $oldInterns = 0;
while (my $file = readdir $dh) {
unless ($file =~ /^\s*(success|faile?d?)-(\S+)\.txt\s*$/i) {
print STDERR "Skipping $file which does not match proper format...\n" if ($VERBOSE >= 2);
@ -175,6 +177,7 @@ while (my $file = readdir $dh) {
foreach my $name (@nameComponents) {
push(@searchTerms, 'Subject LIKE "' . $name . '"');
}
# Find the ticket number for this intern.
my $ticket = FindUniqueTicket(@searchTerms);
if (not defined $ticket) {
foreach my $term (@searchTerms) {
@ -191,7 +194,15 @@ while (my $file = readdir $dh) {
die "interactive mode not yet supported";
}
}
# Find the ticket number for this intern.
my $completedInternshipField = GetCustomFieldForTicket($ticket, "completed-internship");
if (not defined $completedInternshipField) {
print STDERR "\"$file\": \"$ticket\": Skipping: cannot determine Entity from ticket.\n" ;
next;
} elsif ($completedInternshipField eq 'successful') {
# Don't print to STDERR here, just keep a count since these are "old interns"
$oldInterns++;
next;
}
my $entity = LedgerTagFromTicket($ticket, 'Entity');
if (not defined $entity) {
print STDERR "\"$file\": \"$ticket\": Skipping: cannot determine Entity from ticket.\n" ;
@ -227,7 +238,6 @@ while (my $file = readdir $dh) {
}
next;
}
my $completedInternshipField = GetCustomFieldForTicket($ticket, "completed-internship");
my $expectVal = 'payment-' . $prevPayNum . "-approved";
if ($completedInternshipField ne $expectVal) {
print STDERR "\"$file\": \"$ticket\": Skipped: completed-internship field was ",
@ -258,6 +268,7 @@ while (my $file = readdir $dh) {
next;
}
}
print STDERR "Old Interns, who were marked as successful (likely from previous interns) ignored: $oldInterns\n";
###############################################################################
#
# Local variables: