• R/O
  • SSH
  • HTTPS

traclight: Commit


Commit MetaInfo

Revision118 (tree)
Zeit2010-12-10 23:48:37
Autorokamototk

Log Message

add estimated line and support empty component.

Ändern Zusammenfassung

Diff

--- branches/tl3_0/plugins/svn/scrumburndownplugin/burndown/htdocs/js/line.js (revision 117)
+++ branches/tl3_0/plugins/svn/scrumburndownplugin/burndown/htdocs/js/line.js (revision 118)
@@ -84,7 +84,7 @@
8484 this.max = parseInt(value,10);
8585 }
8686
87- this.render = function(canvas, title, height)
87+ this.render = function(canvas, title, height, colPtr)
8888 {
8989 var jg = new jsGraphics(canvas);
9090
@@ -111,7 +111,7 @@
111111 }
112112
113113 // Draw the line graph
114- var color = this.getColor();
114+ var color = colPtr; //this.getColor();
115115 var oldx, oldy;
116116 jg.setStroke(1);
117117
@@ -125,7 +125,7 @@
125125 jg.drawLine(oldx, h-oldy, sx, h-ht1);
126126 }
127127
128- jg.setColor("red");
128+ jg.setColor(colPtr);
129129 jg.fillEllipse(sx-2, h-ht1-2, 5, 5);
130130
131131 jg.setColor("black");
--- branches/tl3_0/plugins/svn/scrumburndownplugin/burndown/burndown.py (revision 117)
+++ branches/tl3_0/plugins/svn/scrumburndownplugin/burndown/burndown.py (revision 118)
@@ -18,7 +18,7 @@
1818
1919 from trac import __version__ as tracversion_runtime
2020
21-from datetime import datetime
21+from datetime import datetime, date
2222
2323 from trac.core import *
2424 from trac.config import BoolOption
@@ -29,6 +29,7 @@
2929 from trac.util import escape, Markup, format_date
3030 from trac.ticket import ITicketChangeListener
3131 from trac.ticket import model
32+from trac.util.datefmt import to_datetime
3233
3334 class BurndownComponent(Component):
3435 implements(IEnvironmentSetupParticipant, INavigationContributor,
@@ -169,7 +170,9 @@
169170 self.update_burndown_data()
170171
171172 data['burndown_data'] = req.hdf['burndown_data'] = []
172- data['burndown_data'] = req.hdf['burndown_data'] = self.get_burndown_data(db, selected_milestone, components, selected_component)
173+ burndown_data, estimated_data = self.get_burndown_data(db, selected_milestone, components, selected_component)
174+ data['burndown_data'] = req.hdf['burndown_data'] = burndown_data
175+ data['estimated_data'] = req.hdf['estimated_data'] = estimated_data
173176
174177 add_stylesheet(req, 'hw/css/burndown.css')
175178
@@ -188,17 +191,24 @@
188191 add_script(req, 'hw/js/wz_jsgraphics.js')
189192
190193 return 'burndown.html', data, None
191-
192-
194+
195+
193196 def get_burndown_data(self, db, selected_milestone, components, selected_component):
194197 cursor = db.cursor()
195-
198+ cursor.execute("SELECT due FROM milestone where name='%s'" % selected_milestone['name']);
199+ milestone_due = cursor.fetchone()[0];
200+ self.log.info("milestone_due:")
201+ self.log.info(milestone_due)
202+ t = to_datetime(milestone_due)
203+ due_milestone = datetime(t.year,t.month,t.day)
204+
205+ delta = None
196206 component_data = {} # this will be a dictionary of lists of tuples -- e.g. component_data = {'componentName':[(id, hours_remaining), (id, hours_remaining), (id, hours_remaining)]}
197207 for comp in components:
198208 if selected_component == 'All Components' or comp['name'] == selected_component:
199209 self.log.debug("comp = %s", comp['name'])
200- self.log.debug("selected_component = %s", selected_component)
201- sqlBurndown = "SELECT id, hours_remaining "\
210+ self.log.debug("selected_component = %s", sselected_component)
211+ sqlBurndown = "SELECT id, hours_remaining ,date"\
202212 "FROM burndown "\
203213 "WHERE milestone_name = %s AND component_name = %s "\
204214 "ORDER BY id"
@@ -211,7 +221,7 @@
211221 if selected_component == 'All Components' or comp['name'] == selected_component:
212222 self.log.debug("comp = %s", comp['name'])
213223 self.log.debug("selected_component = %s", selected_component)
214- sqlBurndown = "SELECT id, hours_remaining "\
224+ sqlBurndown = "SELECT id, hours_remaining, date "\
215225 "FROM burndown "\
216226 "WHERE milestone_name = %s AND component_name = %s "\
217227 "ORDER BY id"
@@ -228,6 +238,7 @@
228238 for time_unit in range (0, burndown_length):
229239 sumHours = 0
230240 for comp in components:
241+ plotdata.append(comp['date'])
231242 self.log.debug('component: %s', [comp['name']]);
232243 self.log.debug('time_unit: %s', [time_unit]);
233244 if (component_data[comp['name']] and len(component_data[comp['name']]) > time_unit):
@@ -245,9 +256,25 @@
245256
246257 else:
247258 for time_unit in range (0, len(component_data[selected_component])):
259+ plotdata.append(component_data[selected_component]['date'])
248260 burndown_data.append((time_unit+1, component_data[selected_component][time_unit][1]))
249-
250- return burndown_data
261+ start_milestone = None
262+ estimated_data = []
263+ if len(burndown_data)!=0:
264+ if len(components)==0:
265+ t = time.strptime(component_data['-'][0][2],'%Y/%m/%d')
266+ start_milestone = datetime(t[0] ,t[1] ,t[2])
267+ else:
268+ t = time.strptime(component_data[component_data.keys()[0]][0][2],'%Y/%m/%d')
269+ start_milestone = datetime(t[0] ,t[1] ,t[2])
270+ initial_estimated = burndown_data[0][1]
271+
272+ term = (due_milestone - start_milestone).days
273+
274+ for time_unit in range (0,term):
275+ estimated_data.append((time_unit+1 ,initial_estimated*(1-float(time_unit+1)/term) ))
276+
277+ return (burndown_data, estimated_data)
251278
252279 def start_milestone(self, db, milestone):
253280 startdate = dbhelper.get_startdate_for_milestone(db, milestone)
--- branches/tl3_0/plugins/svn/scrumburndownplugin/burndown/templates/burndown.html (revision 117)
+++ branches/tl3_0/plugins/svn/scrumburndownplugin/burndown/templates/burndown.html (revision 118)
@@ -86,13 +86,17 @@
8686
8787 <script>
8888 var g = new line_graph();
89-
89+ var e = new line_graph();
9090 <py:for each="row in burndown_data">
9191 g.add('${row[0]}', ${row[1]});
9292 </py:for>
93+ <py:for each="row in estimated_data">
94+ e.add('${row[0]}', ${row[1]});
95+ </py:for>
9396
9497 //If called without a height parameter, defaults to 250
95- g.render("burndownGraph", "hours remaining vs. days of sprint", 300);
98+ e.render("burndownGraph", "残り時間とスプリント日数", 300, "skyblue");
99+ g.render("burndownGraph", "", 300, "red");
96100
97101 </script>
98102 </py:otherwise>
Show on old repository browser