Commits

Marius Gedminas committed bf5d9d6

Highlight age column by age.

Comments (0)

Files changed (2)

         profiles.sort(reverse=True)
         errors.sort(reverse=True)
         res = Response()
+        if profiles:
+            earliest = profiles[-1][0]
+        else:
+            earliest = None
         res.body = self.render('/list_profiles.mako', profiles=profiles,
-                               errors=errors, now=time.time())
+                               errors=errors, now=time.time(),
+                               earliest=earliest)
         return res
     showall.exposed = True
 

dozer/templates/list_profiles.mako

         <th class="delete"></th>
     </tr>
     % for created_time, environ, total_cost, profile_id in profiles:
+    <%
+        w = (now-created_time) / (now-earliest)  # 0 .. 1
+        w = 1 - w
+        w = round(w * 255)
+        bg = '#%02x%02x%02x' % (w, w, w)
+        if w > 128:
+            fg = 'black'
+        else:
+            fg = 'white'
+    %>
     <tr pid="${profile_id}">
         <td class="url">${environ['SCRIPT_NAME'] + environ['PATH_INFO'] + environ['QUERY_STRING']|h}</td>
         <td class="cost">${total_cost} ms</td>
-        <td class="time">${'%i' % int(now-created_time)} seconds ago</td>
+        <td class="time" style="background: ${bg}; color: ${fg};">${'%i' % int(now-created_time)} seconds ago</td>
         <td class="pid"><a href="/_profiler/show/${profile_id}">${profile_id}</a></td>
         <td class="delete"><a href="/_profiler/delete/${profile_id}" class="delete">delete</a></td>
     </tr>