alphagov/whitehall — pull request #1753 by tekin (2014-10-06 14:17:11+00:00)
Title: Precompute HTML attachment govspeak

There are some HTML attachments that are so large, it takes longer than the 15 second nginx timeout to convert the govspeak to HTML when rendering them on the public-facing site (e.g. the "VAT Notice 700: the VAT guide" publication). The timeout causes a cached version of the page to be returned to the user instead of the latest version. This pull request moves the work of converting govspeak into HTML into a background job such that we can simply display the precomputed HTML instead of processing the govspeak on the fly during the request cycle.

The work has been completed in such a way as to cause minimum disruption to the running site:

* If a precomputed version is not available, the govspeak is processed on the fly as before.
* The code gracefully copes with the in-between state before the data migration has completed (i.e. `HtmlAttachment` does not have a `GovspeakContent` instant yet).
* Cleaning up the existing database column and interim code will follow in a separate pull request.

There will be some minor impact on admin users during the deployment of this feature: until the data migration is complete, they will not be able to edit any HTML Attachments - the "body" field will not appear on the edit form. Once the data migration is complete (takes about 2 minutes), the "body" field will appear as normal.

The data migration will result in jobs being queued for every `HtmlAttachment` in the system to compute the HTML (approximately 12K). It will take some time for all these jobs to be processed, but there should not be any noticeable user impact whilst this is happening.

Story: https://www.agileplannerapp.com/boards/173808/cards/6159