[Backport] Fixing method total_closed_points_by_date for milestone model
parent
67e2ec6905
commit
21520aaf76
|
@ -124,18 +124,22 @@ class Milestone(WatchedModelMixin, models.Model):
|
||||||
user_stories[us.id] = us
|
user_stories[us.id] = us
|
||||||
|
|
||||||
tasks = self.tasks.\
|
tasks = self.tasks.\
|
||||||
select_related("user_story").\
|
select_related("user_story").\
|
||||||
exclude(finished_date__isnull=True).\
|
exclude(finished_date__isnull=True).\
|
||||||
exclude(user_story__isnull=True)
|
exclude(user_story__isnull=True)
|
||||||
|
|
||||||
# For each finished task we try to know the proporional part of points
|
# 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
|
# it represetnts from the user story and add it to the closed points
|
||||||
# for that date
|
# for that date
|
||||||
# This calulation is the total user story points divided by its number of tasks
|
# This calulation is the total user story points divided by its number of tasks
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
user_story = user_stories[task.user_story.id]
|
user_story = user_stories.get(task.user_story.id, None)
|
||||||
total_us_points = user_story._total_us_points
|
if user_story is None:
|
||||||
us_tasks_counter = user_story.num_tasks
|
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
|
# If the task was finished before starting the sprint it needs
|
||||||
# to be included
|
# to be included
|
||||||
|
@ -144,7 +148,9 @@ class Milestone(WatchedModelMixin, models.Model):
|
||||||
finished_date = self.estimated_start
|
finished_date = self.estimated_start
|
||||||
|
|
||||||
points_by_date = self._total_closed_points_by_date.get(finished_date, 0)
|
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
|
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
|
# At this point self._total_closed_points_by_date keeps a dict where the
|
||||||
|
|
Loading…
Reference in New Issue