示例#1
0
    def get_allocation_dict(self):
        if not self.allocation:
            return {}
        #Don't move it up. Circular reference.
        from django.conf import settings
        from service.allocation import core_instance_time, get_burn_time,\
            delta_to_minutes, delta_to_hours, get_delta
        delta = get_delta(self, time_period=settings.FIXED_WINDOW)
        #Keeps the times on these calculations consistent!
        now_time = timezone.now()
        time_used, _ = core_instance_time(self.identity.created_by,
                                          self.identity.id,
                                          delta,
                                          now_time=now_time)
        hours_used = delta_to_hours(time_used)

        burn_time = get_burn_time(self.identity.created_by,
                                  self.identity.id,
                                  delta,
                                  timedelta(minutes=self.allocation.threshold),
                                  now_time=now_time)

        zero_time = now_time + burn_time if burn_time else None
        burned_per_hour = delta_to_hours(burn_time)

        allocation_dict = {
            "threshold": floor(self.allocation.threshold / 60),
            "current": hours_used,
            "delta": ceil(delta.total_seconds() / 60),
            "burn": burned_per_hour,
            "ttz": zero_time,
        }
        return allocation_dict
示例#2
0
    def get_allocation_dict(self):
        if not self.allocation:
            return {}
        #Don't move it up. Circular reference.
        from django.conf import settings
        from service.allocation import core_instance_time, get_burn_time,\
            delta_to_minutes, delta_to_hours, get_delta
        delta = get_delta(self, time_period=settings.FIXED_WINDOW)
        #Keeps the times on these calculations consistent!
        now_time = timezone.now()
        time_used, _ = core_instance_time(self.identity.created_by,
                             self.identity.id,
                             delta,
                             now_time=now_time)
        hours_used = delta_to_hours(time_used)

        burn_time = get_burn_time(self.identity.created_by, self.identity.id,
                                  delta,
                                  timedelta(minutes=self.allocation.threshold),
                                  now_time=now_time)

        zero_time = now_time + burn_time if burn_time else None
        burned_per_hour = delta_to_hours(burn_time)

        allocation_dict = {
            "threshold": floor(self.allocation.threshold/60),
            "current": hours_used,
            "delta": ceil(delta.total_seconds()/60),
            "burn": burned_per_hour,
            "ttz": zero_time,
        }
        return allocation_dict
示例#3
0
 def get_allocation_dict(self):
     if not self.allocation:
         return {}
     #Don't move it up. Circular reference.
     from service.allocation import get_time, get_burn_time,\
         delta_to_minutes, delta_to_hours, get_delta
     delta = get_delta(self, time_period=relativedelta(day=1, months=1))
     time_used = get_time(self.identity.created_by,
                          self.identity.id,
                          delta)
     burn_time = get_burn_time(self.identity.created_by, self.identity.id,
                               delta,
                               timedelta(minutes=self.allocation.threshold))
     mins_consumed = delta_to_minutes(time_used)
     if burn_time:
         burn_time = delta_to_hours(burn_time)
     zero_time = datetime.now() + timedelta(
             minutes=(self.allocation.threshold - mins_consumed))
     allocation_dict = {
         "threshold": floor(self.allocation.threshold/60),
         "current": floor(mins_consumed/60),
         "delta": ceil(delta.total_seconds()/60),
         "burn": burn_time,
         "ttz": zero_time,
     }
     return allocation_dict
示例#4
0
 def get_allocation_dict(self):
     if not self.allocation:
         return {}
     #Don't move it up. Circular reference.
     from service.allocation import get_time, get_burn_time,\
         delta_to_minutes, delta_to_hours, get_delta
     delta = get_delta(self, time_period=relativedelta(day=1, months=1))
     time_used = get_time(self.identity.created_by, self.identity.id, delta)
     burn_time = get_burn_time(self.identity.created_by, self.identity.id,
                               delta,
                               timedelta(minutes=self.allocation.threshold))
     mins_consumed = delta_to_minutes(time_used)
     if burn_time:
         burn_time = delta_to_hours(burn_time)
     zero_time = datetime.now() + timedelta(
         minutes=(self.allocation.threshold - mins_consumed))
     allocation_dict = {
         "threshold": floor(self.allocation.threshold / 60),
         "current": floor(mins_consumed / 60),
         "delta": ceil(delta.total_seconds() / 60),
         "burn": burn_time,
         "ttz": zero_time,
     }
     return allocation_dict
示例#5
0
    def get_allocation_dict(self):
        if not self.allocation:
            return {}
        #Don't move it up. Circular reference.
        from service.allocation import get_time, get_burn_time,\
            delta_to_minutes, delta_to_hours
        time_used = get_time(self.identity.created_by,
                             self.identity.id,
                             timedelta(
                                 minutes=self.allocation.delta))
        burn_time = get_burn_time(self.identity.created_by, self.identity.id,
                                  timedelta(minutes=self.allocation.delta),
                                  timedelta(minutes=self.allocation.threshold))
        mins_consumed = delta_to_minutes(time_used)
        if burn_time:
            burn_time = delta_to_hours(burn_time)

        allocation_dict = {
            "threshold": floor(self.allocation.threshold/60),
            "current": floor(mins_consumed/60),
            "delta": self.allocation.delta,
            "burn": burn_time,
            "ttz": (self.allocation.threshold - mins_consumed)/60}
        return allocation_dict