Rework GetLinksForTicket, returns hash now

Include the Hash Id.
This commit is contained in:
Bradley M. Kuhn 2018-08-05 19:15:51 -07:00
parent c87c215a87
commit 38f7b0cedc
2 changed files with 20 additions and 16 deletions

View file

@ -44,6 +44,23 @@ sub Outreachy_FindMainTicketsInRound($) {
return @ticketSpecs;
}
###############################################################################
sub GetLinksForTicket($) {
my($ticketSpec) = @_;
my %linked;
open(my $rtLinksFH, "-|", "$RT_CMD", "show", $ticketSpec . '/links');
my $type = 'NONE';
while (my $linksLine = <$rtLinksFH>) {
if ($linksLine =~ m%\s*([^:]+)\s:%) {
$type = $1;
}
if ($linksLine =~ m%rt.*(ticket/\d+)\s*,?\s*$%) {
push(@{$linked{$type}}, $1) if $type !~ /(NONE|id)/i;
}
}
close $rtLinksFH;
return %linked;
}
###############################################################################
sub PaymentDateByTicket($$) {
my($ticketSpec, $paymentNumber) = @_;
open(my $rtPayFH, "-|", "$RT_CMD", "show", "-f", 'CF.{payment-' . $paymentNumber . '-sent}', $ticketSpec);

View file

@ -51,19 +51,6 @@ sub AllFormattedLedgerTagFromTicket($) {
return @tags;
}
###############################################################################
sub GetLinksForTicket($) {
my($ticketSpec) = @_;
my @linked;
open(my $rtLinksFH, "-|", "$RT_CMD", "show", $ticketSpec . '/links');
while (my $linksLine = <$rtLinksFH>) {
if ($linksLine =~ m%rt.*(ticket/\d+)\s*,?\s*$%) {
push(@linked, $1);
}
}
close $rtLinksFH;
return @linked;
}
###############################################################################
sub FindTaxTicketFromList(@) {
my $taxTicket;
foreach my $ticket (@_) {
@ -264,16 +251,16 @@ while (my $file = readdir $dh) {
next;
}
my(@links) = GetLinksForTicket($ticket);
my(%links) = GetLinksForTicket($ticket);
if ($VERBOSE > 5) {
print STDERR "\"$file\": \"$ticket\": Found the following links: " , join( ", ", @links), "\n";
}
my $taxTicket = FindTaxTicketFromList(@links);
my $taxTicket = FindTaxTicketFromList(@{$links{DependsOn});
if (not defined $taxTicket) {
print STDERR "\"$file\": \"$ticket\": Skipped: no tax ticket found.\n";
next;
}
my $reimbursementTicket = FindReimbursementTicketFromList(@links);
my $reimbursementTicket = FindReimbursementTicketFromList(@{$links{Members}});
if (not defined $reimbursementTicket) {
print STDERR "\"$file\": \"$ticket\": Skipped: no reimbursement ticket found.\n";
next;