Skip to content

Commit

Permalink
add ideal burndown plot; fix points bug
Browse files Browse the repository at this point in the history
  • Loading branch information
groovecoder committed Mar 28, 2012
1 parent 6bf0a7c commit 2e2118f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 35 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -8,3 +8,4 @@ python-dateutil==1.5
slumber
simplejson
nose==1.1.2
mock==0.8.0
2 changes: 1 addition & 1 deletion scrum/models.py
Expand Up @@ -189,7 +189,7 @@ def is_assigned(self):
return self.assigned_to['name'] != 'nobody'

def points_for_date(self, date):
cpoints = 0
cpoints = self.points
for h in self.points_history:
if date < h['date']:
return cpoints
Expand Down
2 changes: 1 addition & 1 deletion scrum/templates/scrum/sprint.html
Expand Up @@ -151,7 +151,7 @@ <h4>Last updated: {{ sprint.date_cached|timesince }} ago</h4>

var BUGS_DATA = {{ bugs_data_json|safe }};
init_sprint();
new Burndown('#burndown', BUGS_DATA.burndown, BUGS_DATA.burndown_axis);
new Burndown('#burndown', BUGS_DATA);
new PieFlot('#component-pie', BUGS_DATA.components);
new PieFlot('#user-pie', BUGS_DATA.users);
new PieFlot('#status-pie', BUGS_DATA.basic_status, {
Expand Down
17 changes: 16 additions & 1 deletion scrum/tests.py
Expand Up @@ -6,12 +6,13 @@
"""
from datetime import date

from mock import patch
from nose.tools import eq_, ok_

from django.test import TestCase

from forms import SprintForm
from models import Sprint
from models import Sprint, Bug


GOOD_BZ_URL = "https://bugzilla.mozilla.org/buglist.cgi?list_id=2692959;"
Expand All @@ -27,6 +28,20 @@
"target_milestone=2.7;known_name=mdn_20120410"


class TestBug(TestCase):
fixtures = ['test_data.json']

def setUp(self):
self.s = Sprint.objects.get(slug='2.2')

@patch.object(Bug, 'points_history')
def test_points_for_date_default(self, mock_bug):
""" should default to points in whiteboard """
bugs = self.s.get_bugs()
b = bugs[0]
eq_(b.points, b.points_for_date(date.today()))


class TestSprint(TestCase):
fixtures = ['test_data.json']

Expand Down
68 changes: 36 additions & 32 deletions static/js/sprint.js
@@ -1,14 +1,44 @@
(function(){
"use strict";

window.Burndown = function(selector, data, ticks) {
window.Burndown = function(selector, bugs_data) {
var self = this;
self.$element = $(selector);
self.data = data;
self.ticks = ticks;
self.tip_cache = {};

self.$element.data('flot', self);
self.ticks = bugs_data.burndown_axis;
self.tip_cache = {};
self.base_options = {
xaxis: {
mode: 'time',
ticks: self.ticks,
min: self.ticks[0],
max: self.ticks[self.ticks.length-1]
},
yaxis: {
min: 0,
tickSize: 2,
tickFormatter: parseInt
},
grid: {
hoverable: true,
clickable: true,
markings: self.weekend_areas
},
lines: {
show: true,
fill: 0.4
},
points: {
show: true,
fill: true,
radius: 4
}
};
self.actual_plot = {data: bugs_data.burndown, color: '#049cdb'}
self.ideal_plot = {data: [
[bugs_data.burndown_axis[0], bugs_data['total_points']],
[bugs_data.burndown_axis[bugs_data.burndown_axis.length-1], 0]
], lines: {fill: false}, points: {show: false}, color: '#0f0'};

self.resize = function(){
self.$element.css('height', function(){
Expand Down Expand Up @@ -60,33 +90,7 @@

self.resize();

$.plot(self.$element, [{data: self.data, color: '#049cdb'}], {
xaxis: {
mode: 'time',
ticks: self.ticks,
min: self.ticks[0],
max: self.ticks[self.ticks.length-1]
},
yaxis: {
min: 0,
tickSize: 2,
tickFormatter: parseInt
},
grid: {
hoverable: true,
clickable: true,
markings: self.weekend_areas
},
lines: {
show: true,
fill: 0.4
},
points: {
show: true,
fill: true,
radius: 4
}
});
$.plot(self.$element, [self.actual_plot, self.ideal_plot], self.base_options);

self.$element.bind({
plothover: self.plothover,
Expand Down

0 comments on commit 2e2118f

Please sign in to comment.