Fixing method total_closed_points_by_date for milestone model

remotes/origin/issue/4795/notification_even_they_are_disabled
Alejandro Alonso 2016-10-11 08:58:25 +02:00
parent 922571c56b
commit 8c3fed2088
1 changed files with 13 additions and 7 deletions

View File

@ -124,18 +124,22 @@ class Milestone(WatchedModelMixin, models.Model):
user_stories[us.id] = us
tasks = self.tasks.\
select_related("user_story").\
exclude(finished_date__isnull=True).\
exclude(user_story__isnull=True)
select_related("user_story").\
exclude(finished_date__isnull=True).\
exclude(user_story__isnull=True)
# For each finished task we try to know the proporional part of points
# it represetnts from the user story and add it to the closed points
# for that date
# This calulation is the total user story points divided by its number of tasks
for task in tasks:
user_story = user_stories[task.user_story.id]
total_us_points = user_story._total_us_points
us_tasks_counter = user_story.num_tasks
user_story = user_stories.get(task.user_story.id, None)
if user_story is None:
total_us_points = 0
us_tasks_counter = 0
else:
total_us_points = user_story._total_us_points
us_tasks_counter = user_story.num_tasks
# If the task was finished before starting the sprint it needs
# to be included
@ -144,7 +148,9 @@ class Milestone(WatchedModelMixin, models.Model):
finished_date = self.estimated_start
points_by_date = self._total_closed_points_by_date.get(finished_date, 0)
points_by_date += total_us_points / us_tasks_counter
if us_tasks_counter != 0:
points_by_date += total_us_points / us_tasks_counter
self._total_closed_points_by_date[finished_date] = points_by_date
# At this point self._total_closed_points_by_date keeps a dict where the