2020-01-29 00:51:45 +01:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
2021-05-05 04:25:02 +02:00
|
|
|
/**
|
|
|
|
* Compute median.
|
|
|
|
*
|
|
|
|
* @param date
|
|
|
|
* the date
|
|
|
|
* @return the double
|
|
|
|
*/
|
|
|
|
public double computeMedian(final LocalDate date)
|
|
|
|
{
|
|
|
|
double result;
|
|
|
|
|
|
|
|
LongList values = new LongList();
|
|
|
|
for (Issue issue : this)
|
|
|
|
{
|
|
|
|
int age = issue.getAgeInDays(date);
|
|
|
|
values.add(Long.valueOf(age));
|
|
|
|
}
|
|
|
|
|
|
|
|
result = values.median();
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-01-29 00:51:45 +01:00
|
|
|
/**
|
|
|
|
* Compute stat.
|
|
|
|
*
|
|
|
|
* @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)
|
|
|
|
{
|
2020-01-29 14:10:50 +01:00
|
|
|
if (issue.isActiveAt(date))
|
2020-01-29 00:51:45 +01:00
|
|
|
{
|
|
|
|
result.add(issue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
2020-01-29 20:28:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extract actived between.
|
|
|
|
*
|
|
|
|
* @param start
|
|
|
|
* the start
|
|
|
|
* @param end
|
|
|
|
* the end
|
|
|
|
* @return the issues
|
|
|
|
*/
|
|
|
|
public Issues extractActivedBetween(final LocalDate start, final LocalDate end)
|
|
|
|
{
|
|
|
|
Issues result;
|
|
|
|
|
|
|
|
result = new Issues();
|
|
|
|
|
|
|
|
for (Issue issue : this)
|
|
|
|
{
|
|
|
|
if (issue.isActiveBetween(start, end))
|
|
|
|
{
|
|
|
|
result.add(issue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
2020-01-30 03:07:52 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort.
|
|
|
|
*
|
|
|
|
* @param sorting
|
|
|
|
* the sorting
|
|
|
|
* @return the issues
|
|
|
|
*/
|
|
|
|
public Issues sort(final IssueComparator.Sorting sorting)
|
|
|
|
{
|
|
|
|
Issues result;
|
|
|
|
|
|
|
|
sort(new IssueComparator(sorting));
|
|
|
|
|
|
|
|
result = this;
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort by created on.
|
|
|
|
*
|
|
|
|
* @return the issues
|
|
|
|
*/
|
|
|
|
public Issues sortByCreatedOn()
|
|
|
|
{
|
|
|
|
Issues result;
|
|
|
|
|
|
|
|
result = sort(IssueComparator.Sorting.CREATEDON);
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort by id.
|
|
|
|
*
|
|
|
|
* @return the issues
|
|
|
|
*/
|
|
|
|
public Issues sortById()
|
|
|
|
{
|
|
|
|
Issues result;
|
|
|
|
|
|
|
|
result = sort(IssueComparator.Sorting.ID);
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sort by identifier.
|
|
|
|
*
|
|
|
|
* @return the issues
|
|
|
|
*/
|
|
|
|
public Issues sortByProjectId()
|
|
|
|
{
|
|
|
|
Issues result;
|
|
|
|
|
|
|
|
result = sort(IssueComparator.Sorting.PROJECTID);
|
|
|
|
|
|
|
|
//
|
|
|
|
return result;
|
|
|
|
}
|
2020-01-29 00:51:45 +01:00
|
|
|
}
|