Modify ↓
Opened 16 years ago
Last modified 7 years ago
#4998 assigned enhancement
Optimize a lot the Roadmap
Reported by: | Sébastien Lucas | Owned by: | EmeCas |
---|---|---|---|
Priority: | normal | Component: | TracHoursPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.11 |
Description
Hi,
Since I've installed this plugin, I've experienced a lot of slowdown mainly due to the roadmap addition of TracHours (1 second without the plugin to 12~14 second with the plugin to see the roadmap).
Therefore here a patch to return to the old (and good) speed. The trick used to get rid of the date may not be liked but it works (tm).
Index: trachours/hours.py =================================================================== --- trachours/hours.py (révision 5559) +++ trachours/hours.py (copie de travail) @@ -1191,28 +1191,23 @@ db = self.env.get_db_cnx() cursor = db.cursor() - cursor.execute("select id from ticket where milestone='%s'" % milestone.name) - tickets = [i[0] for i in cursor.fetchall()] + cursor.execute("select t.id, c.value, sum (h.seconds_worked) from ticket t left join ticket_custom c on (c.ticket = t.id and c.name = 'estimatedhours') left join ticket_time h on (h.ticket = t.id) where milestone = '%s' group by t.id, c.value" % milestone.name) - if tickets: - hours[milestone.name]['date'] = Ticket(self.env, tickets[0]).time_created - for ticket in tickets: - ticket = Ticket(self.env, ticket) - + for ticket, estimated, whours in cursor: # estimated hours for the ticket try: - estimatedhours = float(ticket['estimatedhours']) + estimatedhours = float(estimated) except (ValueError, TypeError): estimatedhours = 0. hours[milestone.name]['estimatedhours'] += estimatedhours # total hours for the ticket - totalhours = self.get_total_hours(ticket.id) + try: + totalhours = float(whours) + except (ValueError, TypeError): + totalhours = 0. hours[milestone.name]['totalhours'] += totalhours - - # update date for oldest ticket - if ticket.time_created < hours[milestone.name]['date']: - hours[milestone.name]['date'] = ticket.time_created + # seconds -> hours hours[milestone.name]['totalhours'] /= 3600. @@ -1235,11 +1230,10 @@ if estimatedhours: items.append(tag.dt("Estimated Hours:")) items.append(tag.dd(str(estimatedhours))) - date = hours['date'] link = self.href("hours", milestone=milestone, - from_year=date.year, - from_month=date.month, - from_day=date.day) + from_year=1980, + from_month=1, + from_day=1) items.append(tag.dt(tag.a("Total Hours:", href=link))) items.append(tag.dd(tag.a(hours_format % totalhours, href=link))) return iter(tag.dl(*items))
Attachments (0)
Change History (4)
comment:1 Changed 16 years ago by
comment:2 Changed 14 years ago by
Owner: | changed from Jeff Hammel to Ryan J Ollos |
---|
Reassigning ticket to new maintainer.
comment:3 Changed 8 years ago by
Owner: | Ryan J Ollos deleted |
---|
comment:4 Changed 7 years ago by
Owner: | set to EmeCas |
---|---|
Status: | new → assigned |
Note: See
TracTickets for help on using
tickets.
I forgot to say but k0s can use my patch in whatever license he may want.