def process_request(self, req): req.perm.assert_permission("BURNDOWN_VIEW") db = self.env.get_db_cnx() milestones = dbhelper.get_milestones(db) components = dbhelper.get_components(db) selected_milestone = None if len(milestones) > 0: selected_milestone = dbhelper.get_current_milestone(db, req.args.get("selected_milestone", "")) selected_component = req.args.get("selected_component", "All Components") empty_db_for_testing = req.args.get("empty_db_for_testing", "false") if empty_db_for_testing == "true": req.perm.assert_permission("TRAC_ADMIN") dbhelper.empty_db_for_testing(db) # expose display data to the templates data = {} data["milestones"] = req.hdf["milestones"] = milestones data["components"] = req.hdf["components"] = components data["selected_milestone"] = req.hdf["selected_milestone"] = selected_milestone data["selected_component"] = req.hdf["selected_component"] = selected_component data["draw_graph"] = req.hdf["draw_graph"] = False data["start"] = req.hdf["start"] = False if req.perm.has_permission("BURNDOWN_ADMIN"): data["start"] = req.hdf["start"] = True # show the start and complete milestone buttons to admins if req.args.has_key("start"): self.start_milestone(db, selected_milestone["name"]) data["draw_graph"] = req.hdf["draw_graph"] = True self.update_burndown_data() data["burndown_data"] = req.hdf["burndown_data"] = [] data["burndown_data"] = req.hdf["burndown_data"] = self.get_burndown_data( db, selected_milestone, components, selected_component ) add_stylesheet(req, "hw/css/burndown.css") self.update_burndown_data() if self.tracversion == "0.10": add_script(req, "hw/js/line.js") add_script(req, "hw/js/wz_jsgraphics.js") return "burndown.cs", None else: data["library"] = "" if data["library"] == "flot": add_script(req, "hw/js/jquery.flot.js") else: add_script(req, "hw/js/line.js") add_script(req, "hw/js/wz_jsgraphics.js") return "burndown.html", data, None
def process_request(self, req): req.perm.assert_permission('BURNDOWN_VIEW') db = self.env.get_db_cnx() milestones = dbhelper.get_milestones(db) components = dbhelper.get_components(db) selected_milestone = None if (len(milestones)>0): selected_milestone = dbhelper.get_current_milestone(db, req.args.get('selected_milestone', "")) selected_component = req.args.get('selected_component', 'All Components') empty_db_for_testing = req.args.get('empty_db_for_testing', 'false') if empty_db_for_testing == "true": req.perm.assert_permission('TRAC_ADMIN') dbhelper.empty_db_for_testing(db) # expose display data to the templates data = {} data['milestones'] = req.hdf['milestones'] = milestones data['components'] = req.hdf['components'] = components data['selected_milestone'] = req.hdf['selected_milestone'] = selected_milestone data['selected_component'] = req.hdf['selected_component'] = selected_component data['draw_graph'] = req.hdf['draw_graph'] = False data['start'] = req.hdf['start'] = False if req.perm.has_permission("BURNDOWN_ADMIN"): data['start'] = req.hdf['start'] = True # show the start and complete milestone buttons to admins if req.args.has_key('start'): self.start_milestone(db, selected_milestone['name']) data['draw_graph'] = req.hdf['draw_graph'] = True self.update_burndown_data() data['burndown_data'] = req.hdf['burndown_data'] = [] data['burndown_data'] = req.hdf['burndown_data'] = self.get_burndown_data(db, selected_milestone, components, selected_component) add_stylesheet(req, 'hw/css/burndown.css') self.update_burndown_data() if self.tracversion=="0.10": add_script(req, 'hw/js/line.js') add_script(req, 'hw/js/wz_jsgraphics.js') return 'burndown.cs', None else: data['library'] = '' if data['library'] == 'flot': add_script(req, 'hw/js/jquery.flot.js') else: add_script(req, 'hw/js/line.js') add_script(req, 'hw/js/wz_jsgraphics.js') return 'burndown.html', data, None
def update_burndown_data(self): db = self.env.get_db_cnx() cursor = db.cursor() # today's date today = format_date(int(time.time())) milestones = dbhelper.get_milestones(db) components = dbhelper.get_components(db) for mile in milestones: if mile['started'] and not mile['completed']: # milestone started, but not completed for comp in components: sqlSelect = "SELECT est.value AS estimate, ts.value AS spent "\ "FROM ticket t "\ " LEFT OUTER JOIN ticket_custom est ON (t.id = est.ticket AND est.name = 'estimatedhours') "\ " LEFT OUTER JOIN ticket_custom ts ON (t.id = ts.ticket AND ts.name = 'totalhours') "\ "WHERE t.component = %s AND t.milestone = %s"\ " AND status IN ('new', 'assigned', 'reopened', 'accepted') " cursor.execute(sqlSelect, [comp['name'], mile['name']]) rows = cursor.fetchall() hours = 0 estimate = 0 spent = 0 if rows: for estimate, spent in rows: if not estimate: estimate = 0 if not spent: spent = 0 if (float(estimate) - float(spent)) > 0: hours += float(estimate) - float(spent) cursor.execute("SELECT id FROM burndown WHERE date = %s AND milestone_name = %s"\ "AND component_name = %s", [today, mile['name'], comp['name']]) row = cursor.fetchone() try: if row: cursor.execute("UPDATE burndown SET hours_remaining = %s WHERE date = %s AND milestone_name = %s"\ "AND component_name = %s", [hours, today, mile['name'], comp['name']]) else: cursor.execute("INSERT INTO burndown(component_name, milestone_name, date, hours_remaining) "\ " VALUES(%s,%s,%s,%s)", [comp['name'], mile['name'], today, hours]) except Exception, inst: self.log.debug(type(inst)) # the exception instance self.log.debug(inst.args) # arguments stored in .args self.log.debug(inst) # __str__ allows args to printed directly cursor.connection.rollback() else: db.commit()
def process_request(self, req): req.perm.assert_permission('BURNDOWN_VIEW') db = self.env.get_db_cnx() milestones = dbhelper.get_milestones(db) components = dbhelper.get_components(db) selected_milestone = None if len(milestones) > 0: selected_milestone = dbhelper.get_current_milestone( db, req.args.get('selected_milestone', '')) selected_component = req.args.get('selected_component', 'All Components') empty_db_for_testing = req.args.get('empty_db_for_testing', 'false') if empty_db_for_testing == "true": req.perm.assert_permission('TRAC_ADMIN') dbhelper.empty_db_for_testing(db) # expose display data to the templates data = { 'milestones': milestones, 'components': components, 'selected_milestone': selected_milestone, 'selected_component': selected_component, 'draw_graph': True, 'start': req.perm.has_permission('BURNDOWN_ADMIN'), } if 'start' in req.args: self.start_milestone(db, selected_milestone['name']) self.update_burndown_data() data['burndown_data'] = \ self.get_burndown_data(db, selected_milestone, components, selected_component) add_stylesheet(req, 'hw/css/burndown.css') self.update_burndown_data() data['library'] = '' if data['library'] == 'flot': add_script(req, 'hw/js/jquery.flot.js') else: add_script(req, 'hw/js/line.js') add_script(req, 'hw/js/wz_jsgraphics.js') return 'burndown.html', data, None
def update_burndown_data(self): db = self.env.get_db_cnx() cursor = db.cursor() # today's date today = format_date(int(time.time())) milestones = dbhelper.get_milestones(db) components = dbhelper.get_components(db) for mile in milestones: if mile['started'] and not mile['completed']: for comp in components: cursor.execute(""" SELECT est.value AS estimate, ts.value AS spent FROM ticket t LEFT OUTER JOIN ticket_custom est ON (t.id = est.ticket AND est.name = 'estimatedhours') LEFT OUTER JOIN ticket_custom ts ON (t.id = ts.ticket AND ts.name = 'totalhours') WHERE t.component = %s AND t.milestone = %s AND status IN ('new', 'assigned', 'reopened', 'accepted')""", (comp['name'], mile['name'])) rows = cursor.fetchall() hours = 0 if rows: for estimate, spent in rows: if not estimate: estimate = 0 if not spent: spent = 0 if (float(estimate) - float(spent)) > 0: hours += float(estimate) - float(spent) cursor.execute(""" SELECT id FROM burndown WHERE date = %s AND milestone_name = %s AND component_name = %s """, (today, mile['name'], comp['name'])) row = cursor.fetchone() try: if row: cursor.execute(""" UPDATE burndown SET hours_remaining = %s WHERE date = %s AND milestone_name = %s AND component_name = %s """, (hours, today, mile['name'], comp['name'])) else: cursor.execute(""" INSERT INTO burndown(component_name, milestone_name, date, hours_remaining) VALUES(%s,%s,%s,%s) """, (comp['name'], mile['name'], today, hours)) except Exception, inst: self.log.debug(type(inst)) self.log.debug(inst.args) self.log.debug(inst) cursor.connection.rollback() else: db.commit()
def update_burndown_data(self): db = self.env.get_db_cnx() cursor = db.cursor() # today's date today = format_date(int(time.time())) milestones = dbhelper.get_milestones(db) components = dbhelper.get_components(db) for mile in milestones: if mile['started'] and not mile['completed']: for comp in components: cursor.execute( """ SELECT est.value AS estimate, ts.value AS spent FROM ticket t LEFT OUTER JOIN ticket_custom est ON (t.id = est.ticket AND est.name = 'estimatedhours') LEFT OUTER JOIN ticket_custom ts ON (t.id = ts.ticket AND ts.name = 'totalhours') WHERE t.component = %s AND t.milestone = %s AND status IN ('new', 'assigned', 'reopened', 'accepted')""", (comp['name'], mile['name'])) rows = cursor.fetchall() hours = 0 if rows: for estimate, spent in rows: if not estimate: estimate = 0 if not spent: spent = 0 if (float(estimate) - float(spent)) > 0: hours += float(estimate) - float(spent) cursor.execute( """ SELECT id FROM burndown WHERE date = %s AND milestone_name = %s AND component_name = %s """, (today, mile['name'], comp['name'])) row = cursor.fetchone() try: if row: cursor.execute( """ UPDATE burndown SET hours_remaining = %s WHERE date = %s AND milestone_name = %s AND component_name = %s """, (hours, today, mile['name'], comp['name'])) else: cursor.execute( """ INSERT INTO burndown(component_name, milestone_name, date, hours_remaining) VALUES(%s,%s,%s,%s) """, (comp['name'], mile['name'], today, hours)) except Exception, inst: self.log.debug(type(inst)) self.log.debug(inst.args) self.log.debug(inst) cursor.connection.rollback() else: db.commit()
def update_burndown_data(self): db = self.env.get_db_cnx() cursor = db.cursor() # today's date today = format_date(int(time.time())) milestones = dbhelper.get_milestones(db) components = dbhelper.get_components(db) for mile in milestones: if mile["started"] and not mile["completed"]: # milestone started, but not completed for comp in components: sqlSelect = ( "SELECT est.value AS estimate, ts.value AS spent " "FROM ticket t " " LEFT OUTER JOIN ticket_custom est ON (t.id = est.ticket AND est.name = 'estimatedhours') " " LEFT OUTER JOIN ticket_custom ts ON (t.id = ts.ticket AND ts.name = 'totalhours') " "WHERE t.component = %s AND t.milestone = %s" " AND status IN ('new', 'assigned', 'reopened', 'accepted') " ) cursor.execute(sqlSelect, [comp["name"], mile["name"]]) rows = cursor.fetchall() hours = 0 estimate = 0 spent = 0 if rows: for estimate, spent in rows: if not estimate: estimate = 0 if not spent: spent = 0 if (float(estimate) - float(spent)) > 0: hours += float(estimate) - float(spent) cursor.execute( "SELECT id FROM burndown WHERE date = %s AND milestone_name = %s" "AND component_name = %s", [today, mile["name"], comp["name"]], ) row = cursor.fetchone() try: if row: cursor.execute( "UPDATE burndown SET hours_remaining = %s WHERE date = %s AND milestone_name = %s" "AND component_name = %s", [hours, today, mile["name"], comp["name"]], ) else: cursor.execute( "INSERT INTO burndown(component_name, milestone_name, date, hours_remaining) " " VALUES(%s,%s,%s,%s)", [comp["name"], mile["name"], today, hours], ) except Exception, inst: self.log.debug(type(inst)) # the exception instance self.log.debug(inst.args) # arguments stored in .args self.log.debug(inst) # __str__ allows args to printed directly cursor.connection.rollback() else: db.commit()