# Path: kardboard/app.py
#     DEBUG_TOOLBAR = True
#     DEBUG_TOOLBAR = False
#     SENTRY_SUPPORT = True
#     SENTRY_SUPPORT = False
# def get_app():
# 
# Path: kardboard/util.py
# def now():
#     return datetime.datetime.now()
# 
# def make_end_date(year=None, month=None, day=None, date=None):
#     end_date = munge_date(year, month, day, date)
#     end_date = end_date.replace(hour=23, minute=59, second=59)
#     return end_date
# 
# def make_start_date(year=None, month=None, day=None, date=None):
#     start_date = munge_date(year, month, day, date)
#     start_date = start_date.replace(hour=23, minute=59, second=59)
#     start_date = start_date.replace(hour=0, minute=0, second=0)
#     return start_date
# 
# def average(values):
#     """Computes the arithmetic mean of a list of numbers.
# 
#     >>> print average([20, 30, 70])
#     40.0
#     """
#     try:
#         return stats.mean(values)
#     except ZeroDivisionError:
#         return None


from kardboard.app import app
from kardboard.util import (
    now,
    make_end_date,
    make_start_date,
    average,
)
        from kardboard.models import Kard
        from kardboard.models import ReportGroup
        from kardboard.models import Kard
        from kardboard.models import ReportGroup
class ServiceClassRecord(app.db.Document):
    """
    A snapshot of service class metadata, per group,
    within a start and end date.
    """
    start_date = app.db.DateTimeField(required=False,
        unique_with=['group', 'end_date'])
    """The start date for the records"""

    end_date = app.db.DateTimeField(required=False,
        unique_with=['group', 'start_date'])
    """The start date for the records"""

    group = app.db.StringField(required=True, default="all",
        unique_with=['start_date', 'end_date'])
    """The report group to which this daily report belongs."""

    updated_at = app.db.DateTimeField(required=True)
    """The datetime the record was last updated at."""

    data = app.db.DictField(required=False, default={})
    """The report on service classes."""

    def save(self, *args, **kwargs):
        self.updated_at = now()
        super(ServiceClassRecord, self).save(*args, **kwargs)

    @classmethod
    def calculate(cls, start_date, end_date, group="all"):


# Path: kardboard/app.py
#     DEBUG_TOOLBAR = True
#     DEBUG_TOOLBAR = False
#     SENTRY_SUPPORT = True
#     SENTRY_SUPPORT = False
# def get_app():
# 
# Path: kardboard/util.py
# def now():
#     return datetime.datetime.now()
# 
# def make_end_date(year=None, month=None, day=None, date=None):
#     end_date = munge_date(year, month, day, date)
#     end_date = end_date.replace(hour=23, minute=59, second=59)
#     return end_date
# 
# def make_start_date(year=None, month=None, day=None, date=None):
#     start_date = munge_date(year, month, day, date)
#     start_date = start_date.replace(hour=23, minute=59, second=59)
#     start_date = start_date.replace(hour=0, minute=0, second=0)
#     return start_date
# 
# def average(values):
#     """Computes the arithmetic mean of a list of numbers.
# 
#     >>> print average([20, 30, 70])
#     40.0
#     """
#     try:
#         return stats.mean(values)
#     except ZeroDivisionError:
#         return None


# Path: kardboard/models/serviceclassrecord.py
from kardboard.app import app
from kardboard.util import (
    now,
    make_end_date,
    make_start_date,
    average,
)
        from kardboard.models import Kard
        from kardboard.models import ReportGroup
        from kardboard.models import Kard
        from kardboard.models import ReportGroup

class ServiceClassRecord(app.db.Document):
    """
    A snapshot of service class metadata, per group,
    within a start and end date.
    """
    start_date = app.db.DateTimeField(required=False,
        unique_with=['group', 'end_date'])
    """The start date for the records"""

    end_date = app.db.DateTimeField(required=False,
        unique_with=['group', 'start_date'])
    """The start date for the records"""

    group = app.db.StringField(required=True, default="all",
        unique_with=['start_date', 'end_date'])
    """The report group to which this daily report belongs."""

    updated_at = app.db.DateTimeField(required=True)
    """The datetime the record was last updated at."""

    data = app.db.DictField(required=False, default={})
    """The report on service classes."""

    def save(self, *args, **kwargs):
        self.updated_at = now()
        super(ServiceClassRecord, self).save(*args, **kwargs)

    @classmethod
    def calculate(cls, start_date, end_date, group="all"):


        start_date = make_start_date(date=start_date)