# Path: dashboard/models.py
# class ProjectSummary(models.Model):
#     """Summary data about a JIRA filter for a particular date."""
# 
#     filter_id = models.IntegerField()
#     incomplete = models.IntegerField()
#     complete = models.IntegerField()
#     total = models.IntegerField()
#     created_on = models.DateField()
#     updated_at = models.DateTimeField(null=False)
# 
#     class Meta:
#         verbose_name = "project summary"
#         verbose_name_plural = "project summaries"
#         unique_together = (("filter_id", "created_on"))
#         get_latest_by = "updated_at"
# 
#     def __repr__(self):
#         return "<ProjectSummary {} filter: {} created_on: {}>".format(self.id, self.filter_id, self.created_on)
# 
#     @property
#     def pct_complete(self):
#         """How complete is the project.
# 
#         Returns:
#             float: Percentage of the project that is complete.
#         """
#         if self.total == 0:
#             return float(0)
#         return self.complete / float(self.total)


import datetime
from django.utils import timezone
from ..models import ProjectSummary
"""Classes and functions for manipulating and storing summaries."""




SAVED = "saved"
UPDATED = "updated"


def fill_updated_at(summary):
    """Set updated_at to created_on at 11:59 pm UTC"""
    summary.updated_at = timezone.now().replace(
        year=summary.created_on.year,
        month=summary.created_on.month,
        day=summary.created_on.day,
        hour=23,
        minute=59,
        second=59,
    )
    return summary


def create(filter_id, complete, incomplete, total, created_on=None):
    """Create ProjectSummary instances."""
    if created_on is None:
        created_on = datetime.date.today()


# Path: dashboard/models.py
# class ProjectSummary(models.Model):
#     """Summary data about a JIRA filter for a particular date."""
# 
#     filter_id = models.IntegerField()
#     incomplete = models.IntegerField()
#     complete = models.IntegerField()
#     total = models.IntegerField()
#     created_on = models.DateField()
#     updated_at = models.DateTimeField(null=False)
# 
#     class Meta:
#         verbose_name = "project summary"
#         verbose_name_plural = "project summaries"
#         unique_together = (("filter_id", "created_on"))
#         get_latest_by = "updated_at"
# 
#     def __repr__(self):
#         return "<ProjectSummary {} filter: {} created_on: {}>".format(self.id, self.filter_id, self.created_on)
# 
#     @property
#     def pct_complete(self):
#         """How complete is the project.
# 
#         Returns:
#             float: Percentage of the project that is complete.
#         """
#         if self.total == 0:
#             return float(0)
#         return self.complete / float(self.total)


# Path: dashboard/services/summaries.py
import datetime
from django.utils import timezone
from ..models import ProjectSummary

"""Classes and functions for manipulating and storing summaries."""




SAVED = "saved"
UPDATED = "updated"


def fill_updated_at(summary):
    """Set updated_at to created_on at 11:59 pm UTC"""
    summary.updated_at = timezone.now().replace(
        year=summary.created_on.year,
        month=summary.created_on.month,
        day=summary.created_on.day,
        hour=23,
        minute=59,
        second=59,
    )
    return summary


def create(filter_id, complete, incomplete, total, created_on=None):
    """Create ProjectSummary instances."""
    if created_on is None:
        created_on = datetime.date.today()


    p = ProjectSummary(