# Path: dashboard/services/summaries.py
# def for_date_range(filter_id, start_date, end_date=None):
#     """Find all the summaries for a given filter_id and a date range.
#     Args:
#         filter_id (int): The filter_id for the project in question.
#         start_date (Date): The start of the range you want summaries for
#         end_date (Date[today]): The end of the range you want summaries for, default: today
#     Returns:
#         List[ProjectSummary]: 0 or more project summaries for that filter in the range
#     """
#     if end_date is None:
#         end_date = datetime.date.today()
#     return ProjectSummary.objects.filter(
#         filter_id=filter_id,
#         created_on__gte=start_date,
#         created_on__lte=end_date,
#     ).order_by('created_on')


import logging
from better.lib import Forecaster
from .summaries import for_date_range
        if throughput < 0:
            throughput = 0
        history.append(throughput)
    return history


def forecast(throughputs, backlog_size, num_simulations=10000, seed=None):
    """Monte Carlo forecast given the provided backlog and throughput histories.
    Args:
        throughputs (List[int]): Number of items completed per period
        backlog_size (int): How many items remain incomplete
        num_simulations (int: 10000): How many simulations should be run
        seed (None): Provide a seed for the random number generator
    Returns:
        List[int]: The 50th, 80th, and 90th percentile # of periods remaining in the project
    """
    results = Forecaster().forecast(throughputs, backlog_size, num_simulations=num_simulations, seed=seed)
    return [results.percentile(50), results.percentile(80), results.percentile(90)]


def for_project(filter_id, backlog_size, start_date):
    """Forecast a project
    Args:
        filter_id (int): The filter_id for the project in question.
        backlog_size (int): How many items remain incomplete
        start_date (Date): How far back should we look for team history to simulate with
    Returns:
        List[int]: The 50th, 80th, and 90th percentile # of periods remaining in the project
    """
    logger.debug("for_project: {}, {}, {}".format(filter_id, backlog_size, start_date))

# Path: dashboard/services/summaries.py
# def for_date_range(filter_id, start_date, end_date=None):
#     """Find all the summaries for a given filter_id and a date range.
#     Args:
#         filter_id (int): The filter_id for the project in question.
#         start_date (Date): The start of the range you want summaries for
#         end_date (Date[today]): The end of the range you want summaries for, default: today
#     Returns:
#         List[ProjectSummary]: 0 or more project summaries for that filter in the range
#     """
#     if end_date is None:
#         end_date = datetime.date.today()
#     return ProjectSummary.objects.filter(
#         filter_id=filter_id,
#         created_on__gte=start_date,
#         created_on__lte=end_date,
#     ).order_by('created_on')


# Path: dashboard/services/predictions.py
import logging
from better.lib import Forecaster
from .summaries import for_date_range

        if throughput < 0:
            throughput = 0
        history.append(throughput)
    return history


def forecast(throughputs, backlog_size, num_simulations=10000, seed=None):
    """Monte Carlo forecast given the provided backlog and throughput histories.
    Args:
        throughputs (List[int]): Number of items completed per period
        backlog_size (int): How many items remain incomplete
        num_simulations (int: 10000): How many simulations should be run
        seed (None): Provide a seed for the random number generator
    Returns:
        List[int]: The 50th, 80th, and 90th percentile # of periods remaining in the project
    """
    results = Forecaster().forecast(throughputs, backlog_size, num_simulations=num_simulations, seed=seed)
    return [results.percentile(50), results.percentile(80), results.percentile(90)]


def for_project(filter_id, backlog_size, start_date):
    """Forecast a project
    Args:
        filter_id (int): The filter_id for the project in question.
        backlog_size (int): How many items remain incomplete
        start_date (Date): How far back should we look for team history to simulate with
    Returns:
        List[int]: The 50th, 80th, and 90th percentile # of periods remaining in the project
    """
    logger.debug("for_project: {}, {}, {}".format(filter_id, backlog_size, start_date))

    summaries = for_date_range(filter_id, start_date)