akvo-rsr icon indicating copy to clipboard operation
akvo-rsr copied to clipboard

Bug: Excel and PDF reports are slow

Open MichaelAkvo opened this issue 2 years ago • 2 comments

What were you doing?

image

  • Clicked on "Download PDF"
  • Waited for 2 minutes for the PDF

What should've happened?

The PDF and excel should've been generated way more quickly, or at least done asynchronously (email with download link).

My environment

No response

Additional context

The endpoints called are:

  • py-reports/program/<projectID>/program-overview/?format=pdf&download=true&period_start={period_start}&period_end={period_end}
  • py-reports/program/<projectID>/program-overview-table/?format=excel&download=true&period_start={period_start}&period_end={period_end}

MichaelAkvo avatar Jun 08 '22 11:06 MichaelAkvo

For the PDF endpoint, we could move to using headless chromium for printing. Here's a stackoverflow script that uses selenium.

There are multiple ways to do this:

One off call

This means starting Chromium every time a PDF has to be printed. It adds a few seconds to the call.

Persistent background process

A persistent headless Chromium could be run in the background.

Printing services

Chromium is run another container. With a small HTTP process that receives the link to the page to print, Chromium could then open a tab, print it, and the HTTP process would send the PDF back as a response.


To get this "just working" we could start with the "one off" function. It'll be slow than the service, but probably much faster than the current printing process.

MichaelAkvo avatar Jun 09 '22 14:06 MichaelAkvo

They are done asynchronously now, but it doesn't hurt to keep this open.

MichaelAkvo avatar Feb 13 '23 14:02 MichaelAkvo