Code review comment for lp:~gmb/launchpad/subscribers-timeout-bug-471974

Revision history for this message
Graham Binns (gmb) wrote :

This branch fixes bug 471974 by moving the loading of the JSON struct of
subscriber IDs out of the main bug page template. Instead, we'll now
lazily-load it when we actually need it - i.e. when we're loading the
subscribers portlet.

The lazy-loading involves requesting a JSON dump from the server, via a
view designed precisely for that task. This seems a bit hacky, but it's
the quickest way to solve the problem. We will investigate more elegant
solutions later.

The upshot of this is that we shouldn't see any more timeouts on the bug
page due to large numbers of subscribers (especially from dupes).

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/canonical/launchpad/javascript/bugs/bugtask-index.js
  lib/lp/bugs/browser/bug.py
  lib/lp/bugs/browser/bugsubscription.py
  lib/lp/bugs/browser/configure.zcml
  lib/lp/bugs/templates/bug-portlet-subscribers-ids.pt
  lib/lp/bugs/templates/bug-portlet-subscribers.pt
  lib/lp/bugs/templates/bugtask-index.pt

== JSLint notices ==
jslint: No problem found in '/home/graham/canonical/lp-branches/subscribers-timeout-bug-471974/lib/canonical/launchpad/javascript/bugs/bugtask-index.js'.

jslint: 1 file to lint.

== Pylint notices ==

lib/lp/bugs/browser/bug.py
    28: [F0401] Unable to import 'email.MIMEMultipart' (No module named MIMEMultipart)
    29: [F0401] Unable to import 'email.MIMEText' (No module named MIMEText)
    43: [F0401] Unable to import 'lazr.enum' (No module named enum)
    44: [F0401] Unable to import 'lazr.lifecycle.event' (No module named lifecycle)
    45: [F0401] Unable to import 'lazr.lifecycle.snapshot' (No module named lifecycle)
    46: [F0401] Unable to import 'lazr.restful.interfaces' (No module named restful)

lib/lp/bugs/browser/bugsubscription.py
    16: [F0401] Unable to import 'lazr.delegates' (No module named delegates)
    17: [F0401] Unable to import 'lazr.lifecycle.event' (No module named lifecycle)

= Changes made =

== lib/canonical/launchpad/javascript/bugs/bugtask-index.js ==

 - I've added Javascript to load the subscriber_ids struct just before
   loading the contents of the subscribers portlet. This should stop the
   bug page from timing out.
 - Note that, should loading the subscriber ids from the JSON dump time
   out (which is theoretically possible), the portlet will still load.

== lib/lp/bugs/browser/bug.py ==

 - I've removed the subscriber_ids_json property from the BugViewMixin.
   It belongs specifically in our JSON-dumping view.

== lib/lp/bugs/browser/bugsubscription.py ==

 - I've added a BugPortletSubscribersIds view. This contains a
   subscriber_ids_json property, which returns a JSON dump of the
   subscriber IDs for the current bug.

== lib/lp/bugs/browser/configure.zcml ==

 - I've added the ZCML for the new view.

== lib/lp/bugs/templates/bug-portlet-subscribers-ids.pt ==

 - I've added this view to contain the JSON dump.

== lib/lp/bugs/templates/bug-portlet-subscribers.pt ==

 - I've added a link to the bug-portlet-subscribers-ids URL so that we
   can grab it using JS and load the JSON dump from it.

== lib/lp/bugs/templates/bugtask-index.pt ==

 - I've removed the javascript that loaded the subscriber IDs as part of
   the main bug page body, which is what was causing the page to time
   out in the first place.

« Back to merge proposal