示例#1
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
示例#2
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
示例#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
        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