agirstatool/src/org/april/agirstatool/core/Issues.java

129 lines
2.5 KiB
Java

/*
* Copyright (C) 2020 Christian Pierre MOMON <christian.momon@devinsy.fr>
*
* This file is part of AgirStatool, simple key value database.
*
* AgirStatool is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* AgirStatool is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with AgirStatool. If not, see <http://www.gnu.org/licenses/>.
*/
package org.april.agirstatool.core;
import java.time.LocalDate;
import java.util.ArrayList;
/**
* The Class IssueList.
*/
public class Issues extends ArrayList<Issue>
{
private static final long serialVersionUID = -6241164269103539500L;
/**
* Instantiates a new issue list.
*/
public Issues()
{
super();
}
/**
* Instantiates a new issue list.
*
* @param capacity
* the capacity
*/
public Issues(final int capacity)
{
super(capacity);
}
/**
* Compute stat.
*
* @param date
* the date
* @return the stat
*/
public Stat computeStat()
{
Stat result;
result = new Stat();
for (Issue issue : this)
{
int age = issue.getAgeInDays();
result.addValue(age);
}
//
return result;
}
/**
* Compute stat.
*
* @param date
* the date
* @return the stat
*/
public Stat computeStat(final LocalDate date)
{
Stat result;
result = new Stat();
for (Issue issue : this)
{
int age = issue.getAgeInDays(date);
result.addValue(age);
}
//
return result;
}
/**
* Extract aticved at.
*
* @param date
* the date
* @return the issue list
*/
public Issues extractActivedAt(final LocalDate date)
{
Issues result;
result = new Issues();
for (Issue issue : this)
{
LocalDate createdOn = issue.getCreatedOn().toLocalDate();
LocalDate closedOn;
if (issue.getClosedOn() == null)
{
closedOn = null;
}
else
{
closedOn = issue.getClosedOn().toLocalDate();
}
if ((!createdOn.isAfter(date)) && ((issue.getClosedOn() == null) || (!closedOn.isBefore(date))))
{
result.add(issue);
}
}
//
return result;
}
}