Having trouble recreating this in a test or just a local dev instance. It is clear that we could avoid the issue by checking if total_items was 0 and not doing the divide, but it should never be 0 in the first place.
A review of the code seems to show that total_items will always be at least 1, since they are array lengths and those arrays are only created just before the first item is put in them (there is no way out of the function (getWorkItemsDueBefore) that creates those arrays where they can be empty.
Clearly I can just protect the section of code that has the divide by 0 in, probably something like the code below, but with no test and no logical reason for this happening, it feels like the bug lies elsewhere...
class PersonUpcomingWorkView(LaunchpadView):
"""This view displays work items and bugtasks that are due within 60 days
and are assigned to a person (or participants of of a team).
"""
# We'll show bugs and work items targeted to milestones with a due date up
# to DAYS from now.
DAYS = 180
def initialize(self): super(PersonUpcomingWorkView, self).initialize() self.workitem_counts = {} self.bugtask_counts = {} self.milestones_per_date = {} self.progress_per_date = {}
for date, containers in self.work_item_containers: total_items = 0 total_done = 0 milestones = set() self.bugtask_counts[date] = 0 self.workitem_counts[date] = 0
for container in containers: total_items += len(container.items)
if total_items == 0: continue
Having trouble recreating this in a test or just a local dev instance. It is clear that we could avoid the issue by checking if total_items was 0 and not doing the divide, but it should never be 0 in the first place.
https:/ /staging. launchpad. net/~linaro/ +upcomingwork works (currently) so I can't gather extra information from there.
A review of the code seems to show that total_items will always be at least 1, since they are array lengths and those arrays are only created just before the first item is put in them (there is no way out of the function (getWorkItemsDu eBefore) that creates those arrays where they can be empty.
Clearly I can just protect the section of code that has the divide by 0 in, probably something like the code below, but with no test and no logical reason for this happening, it feels like the bug lies elsewhere...
class PersonUpcomingW orkView( LaunchpadView) :
"""This view displays work items and bugtasks that are due within 60 days
and are assigned to a person (or participants of of a team).
"""
# We'll show bugs and work items targeted to milestones with a due date up
# to DAYS from now.
DAYS = 180
def initialize(self):
super( PersonUpcomingW orkView, self).initialize()
self.workitem_ counts = {}
self.bugtask_ counts = {}
self.milestone s_per_date = {}
self.progress_ per_date = {} item_containers :
total_ items = 0
total_ done = 0
milestones = set()
self. bugtask_ counts[ date] = 0
self. workitem_ counts[ date] = 0
total_ items += len(container. items)
continue
for date, containers in self.work_
for container in containers:
if total_items == 0:
if isinstance(
for item in container.items: