def __init__(self, api, user_id, story_is_closed='false', stories_status=[], tags_priorities=[], working_days=None): self.user_id = user_id #User id self.user = api.users.get(user_id) #Taiga API user model self.api = api #Taiga API object self.working_days = working_days if working_days else tools.default_working_days() self.tags_priorities = tags_priorities self.calculate_stats(story_is_closed, stories_status)
def workload_4_next_days(self, priorities, working_days=None, hours_per_day=8): """ Finds the workload for the next days, until the it is lower than the working hours per day The estimation of the workload of lower priority stories includes the points of the most priority stories. """ working_days = working_days if working_days else tools.default_working_days() tags_points_results = self.tags_points() times = [] #List of working days tags_points = {} tags = [tag for tag, priority in sorted(priorities,key=lambda x:x[1]) if tag in tags_points_results.keys()] tags.append('None') total_pts = {} points_sum = 0 #Calculates the first day points for each tag for tag in tags: points_sum += tags_points_results[tag] total_pts[tag] = points_sum #Iterates each working day until the number of points remaining #is lower than the number of working hours per day for date in working_days: times.append(date) for tag in tags: if tag not in total_pts.keys(): continue if tag not in tags_points.keys(): tags_points[tag] = [ ] remaining_hours = total_pts[tag] else: remaining_hours = tags_points[tag][-1]-hours_per_day if remaining_hours<0: remaining_hours = 0 tags_points[tag].append( remaining_hours ) if tags_points[tag][-1]<hours_per_day: tags.remove(tag) break if len(tags)==0: break return times, tags_points