summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2013-09-27 14:31:45 +0100
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2013-09-27 14:31:45 +0100
commit729141a1f4a545fc43a899fd0b83e4e4f5039bd8 (patch)
treeeaebb4dbea9fc0f54c1d0d0944d9054e7cbc31a2
parent3230e01a5cb4b8e11a7fc6af232e909bbca0a0c2 (diff)
downloadroadmap-729141a1f4a545fc43a899fd0b83e4e4f5039bd8.tar.gz
changed the algorithm for collecting burndown data. Now it's capruting interval between major milestonesHEADmaster
Change-Id: I84f7b91889dcaf48b509fff5eb0ac205b0328ae5
-rw-r--r--roadmap/helpers.py51
1 files changed, 39 insertions, 12 deletions
diff --git a/roadmap/helpers.py b/roadmap/helpers.py
index deea928..d770b98 100644
--- a/roadmap/helpers.py
+++ b/roadmap/helpers.py
@@ -29,6 +29,7 @@ from roadmap.models import (
Component,
FixVersion,
Label,
+ Milestone,
Project,
Resolution,
SecurityLevel,
@@ -280,7 +281,17 @@ def get_card_blueprints(card):
def get_component_blueprints(component):
blueprint_type = CardType.objects.get(name="Blueprint")
blueprints = []
- for card in component.card_set.all():
+ from_milestone = Milestone.objects.filter(
+ date__lte=datetime.now(),
+ is_major=True).order_by("-date")[0]
+ start_date = from_milestone.date
+ to_milestone = Milestone.objects.filter(
+ date__gt=datetime.now(),
+ is_major=True).order_by("date")[0]
+ end_date = to_milestone.date
+ for card in component.card_set.filter(
+ fix_version__fix_date__gt=start_date,
+ fix_version__fix_date__lt=end_date):
if card.card_type == blueprint_type:
blueprints.append(card)
else:
@@ -305,18 +316,34 @@ def collect_component_burndown(project):
def collect_burndown(project, card_type, component=None):
- bar_values = Status.objects.filter(card__card_type=card_type).values(
- 'name').annotate(num_cards=Count('card'))
+ blueprint_type = CardType.objects.get(name="Blueprint")
+ from_milestone = Milestone.objects.filter(
+ date__lte=datetime.now(),
+ is_major=True).order_by("-date")[0]
+ start_date = from_milestone.date
+ to_milestone = Milestone.objects.filter(
+ date__gt=datetime.now(),
+ is_major=True).order_by("date")[0]
+ end_date = to_milestone.date
+ cards = Card.objects.filter(
+ project=project,
+ fix_version__fix_date__gt=start_date,
+ fix_version__fix_date__lt=end_date)
+ blueprints = []
+ for card in cards:
+ if card.card_type == blueprint_type:
+ blueprints.append(card)
+ else:
+ blueprints.extend(get_card_blueprints(card))
+
burndown, created = Burndown.objects.get_or_create(project=project)
snapshot = BurndownSnapshot(burndown=burndown, date=datetime.now())
snapshot.save()
- bar_names = []
- for bar in bar_values:
- bar_names.append(bar['name'])
- bbar = BurndownBar(
- snapshot=snapshot, name=bar['name'], value=bar['num_cards'])
+ status_names = settings.JIRA_STATUSES
+ for name in status_names:
+ bbar = BurndownBar(snapshot=snapshot, name=name, value=0)
+ for bp in blueprints:
+ if bp.status.name == name:
+ bbar.value = bbar.value + 1
bbar.save()
- if set(bar_names) != set(settings.JIRA_STATUSES):
- for missing in set(settings.JIRA_STATUSES) - set(bar_names):
- bbar = BurndownBar(snapshot=snapshot, name=missing, value=0)
- bbar.save()
+