-
-
Notifications
You must be signed in to change notification settings - Fork 730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make previously generated reports available for download #10280
Comments
Hello @mkllnk, |
Yes, you can grab this feature. It's a nice one to play with Active Storage. I'm looking forward to seeing your solution. |
Hello @mkllnk My idea was to display a list of downloadable reports somewhere on the page (do not know exactly, may be a 3rd column). Since reports are made within a Job, I thought that I could use CableReady/Stimulus to add a report since it is finished generating, by refreshing just the part we want. On the web page, I could have done (in haml view): call to StimulusJS on the button:
BUT, you still have the possibility to generate PDF/Spreasheets the classic way. Which means I cannot make a simple choice in JS(Stimulus) since the parameters are server side. So, if Jobs are handled only by Job, I can use my technique. Which direction should I take ? ( a bit of a long text, I hope I am clear enough :) I have no problem to explicit some bit of it if needed ) |
Hi! Thank you for working on this. And I had similar ideas when first thinking about this functionality. Having that overview of currently stored reports would be great but we currently don't have an association between user and generated report file. So while it would be great to show the downloadable reports, I would prefer to implement quicker solutions first. This issue describes the case where you see a download link after waiting for ten seconds. And all this will be easier with Active Storage. Would you be willing to start there and maybe submit a PR for Active Storage? |
Hello @mkllnk, Thanks for the clarification. I am getting back at it. |
Hi @cyrillefr, I'm getting to this now as well. Let me know if you have any WIP code already. |
Hello @mkllnk , sorry for the delay. |
I think, I found the solution to add custom behaviour when the report is still being uploaded or has expired: |
Very nice. I did not think one could that easily intercept ActiveStorage requests. |
My latest PR sends links via email: I faced a problem with the ActiveStorage redirect links though. Even though I supplied the |
Mail is a good idea. |
What we should change and why (this is tech debt)
When a report takes a long time, the user may want to leave the desk and download the report later. It would be nice to tell the user that it's taking longer and provide a download link. To allow multiple downloads, we should delay report file deletion to later. We will need a cleanup task which deletes old reports for us.
Implementation
I think that we should leverage Active Storage for storing, downloading and deleting files.
ActiveStorage::Blob.create_and_upload!
). The job will need to know the filename for download by the user.Admin::ReportsController#show
and display a nice message with the link. A URL can be generated withRails.application.routes.url_helpers.url_for(blob)
. We need to check the expiry of the URL and may need to extend it.ActiveStorage::PurgeJob.set(wait: 1.week).perform_later(blob)
.We may want a controller action at some point which checks if the report job completed and the file is available, or if it expired already to display nicer messages to the user. The Active Storage controller will just show an error message when the report is not there.
Context
Follow up from:
Next steps:
Impact and timeline
We are waiting for #10258 to be thoroughly tested in production. Once all instances are running stable with that, we can remove the feature toggle and start work on this issue.
The text was updated successfully, but these errors were encountered: