ADD: added method to calc basic statistics

This commit is contained in:
Dominik Meyer 2018-09-15 21:24:40 +02:00
parent 2eba1f74e5
commit becb533405
No known key found for this signature in database
GPG Key ID: B4C312B600606B64
1 changed files with 76 additions and 0 deletions

View File

@ -554,4 +554,80 @@ sub start
}
=method stats
calculate some basic statistics from the current issue repository
at the moment:
number of open issues
number of assigned issues
number of inprogress issues
number of closed issues
@param none
@return hash with
{open}
{assigned}
{inprogress}
{closed}
{all}
=cut
sub stats
{
my $self = shift;
my $ref = $self->repository->getReference('refs/heads/issues');
my $open = $ref->find("open");
my $closed = $ref->find("closed");
my $assigned = $ref->find("assigned");
my $inprogress = $ref->find("inprogess");
my $ret={};
# get number of all open issues
if (defined($open))
{
$ret->{open}=int($open->get);
}
else
{
$ret->{open}=0;
}
# get number of all assigned issues
if (defined($assigned))
{
$ret->{assigned}=int($assigned->get);
}
else
{
$ret->{assigned}=0;
}
# get number of all inprogress issues
if (defined($inprogress))
{
$ret->{inprogress}=int($inprogress->get);
}
else
{
$ret->{inprogess}=0;
}
# get number of all closed issues
if (defined($closed))
{
$ret->{closed}=int($closed->get);
}
else
{
$ret->{closed}=0;
}
return $ret;
}
1;