Opened 8 years ago

Last modified 2 weeks 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



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/
--- trachours/  (révision 5559)
+++ trachours/  (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'" %
-            tickets = [i[0] for i in cursor.fetchall()]
+            cursor.execute("select, c.value, sum (h.seconds_worked) from ticket t left join ticket_custom c on (c.ticket = and = 'estimatedhours') left join ticket_time h on (h.ticket = where milestone = '%s' group by, c.value" %

-            if tickets:
-                hours[]['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
-                    estimatedhours = float(ticket['estimatedhours'])
+                    estimatedhours = float(estimated)
                 except (ValueError, TypeError):
                     estimatedhours = 0.
                 hours[]['estimatedhours'] += estimatedhours

                 # total hours for the ticket
-                totalhours = self.get_total_hours(
+                try:
+                    totalhours = float(whours)
+                except (ValueError, TypeError):
+                    totalhours = 0.
                 hours[]['totalhours'] += totalhours
-                # update date for oldest ticket
-                if ticket.time_created < hours[]['date']:
-                    hours[]['date'] = ticket.time_created
             # seconds -> hours
             hours[]['totalhours'] /= 3600.

@@ -1235,11 +1230,10 @@
                 if estimatedhours:
                     items.append(tag.dt("Estimated Hours:"))
-                date = hours['date']
                 link = self.href("hours", milestone=milestone,
-                                 from_year=date.year,
-                                 from_month=date.month,
+                                 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 8 years ago by Sébastien Lucas

I forgot to say but k0s can use my patch in whatever license he may want.

comment:2 Changed 7 years ago by Ryan J Ollos

Owner: changed from Jeff Hammel to Ryan J Ollos

Reassigning ticket to new maintainer.

comment:3 Changed 12 months ago by Ryan J Ollos

Owner: Ryan J Ollos deleted

comment:4 Changed 2 weeks ago by EmeCas

Owner: set to EmeCas
Status: newassigned

Modify Ticket

Change Properties
Set your email in Preferences
as assigned The owner will remain EmeCas.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.