openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.11k stars 718 forks source link

Show generated report to user however long it takes #10752

Closed mkllnk closed 1 year ago

mkllnk commented 1 year ago

What we should change and why (this is tech debt)

After #10732, we display a generic timeout message when a report takes too long and we'll email a link to the report via email when it's done. But we also want to display the report or at least a download link when it's done. We can use cable_ready channel broadcasting for this.

Context

Follow up from:

Impact and timeline

mkllnk commented 1 year ago

I'm just getting familiar with cable_ready. We haven't done any broadcasts in OFN yet. My work-in-progress commits:

My plan is to replace the current timeout with an instant "Loading..." message and replace that message with the report once it's done. If the report is rendered as HTML, we can replace the HTML in the browser. If it's a downloadable report I suggest we just display a download link. That's an additional click to the current UX though and we can think about redirecting to the URL for download. Need to test browser behaviour here.

One gotcha could be that the report may be generated before the client renders the "Loading..." page. I read that the broadcast wouldn't work in that case. Not sure if we can have a queue or trigger the report in a reflex so that the page is already loaded when the report is triggered.

Resources I found useful:

jibees commented 1 year ago

My plan is to replace the current timeout with an instant "Loading..." message and replace that message with the report once it's done.

After some seconds/minutes, I suppose you want to change the message with a "This report takes a long time to generate, we will send you an email with a link to download the report once it's ready"?

If it's a downloadable report I suggest we just display a download link.

Agree.