Hello,
I typically don't recommend generating reports on button push. We have a proper concept of jobs via https://docs.q2developer.com/docs/tutorials/periodic/index.html
There is a possibility of using the on_finish but you don't have visibility into it's progress very easily without building something very custom:
https://docs.q2developer.com/docs/api_references/q2_sdk/http_handlers/base.html#q2_sdk.core.http_handlers.base_handler.Q2BaseRequestHandler.on_finish
This will also struggle to pass code review as a on_finish extension because generating a report can be incredibly expensive in terms of performance. Doing it on a button push means that someone from the bank can unknowingly push the button multiple times which could lead to degraded online banking performance. To understand more specifics I recommend creating a support ticket so we can determine the best case for this particular report.
-Trey
Thanks for your response, Trey.
The extension itself is a Periodic Entrypoint extension, so when this is deployed, it will generate in the background w/o any user interaction to initiate the job. We don't have any intention to offer this as something that can be generated from user interaction, either. The method I described above is the only way I could think of to test this in PTE and not need to wait for an automated job to kick off to see if my changes worked or not. I was hoping somebody else would have encountered this before and been able to provide a better way of doing this.
One option to avoid the issue of on-demand generation inadvertently overloading the DB could be to continue using the periodic extension - but install it to run in PTE on a much more frequent basis there (perhaps once/hour) - and it could first check a "only_run_within_1_hour_of" timestamp set in DbConfig before proceeding with the report generation. If set - and at each periodic run it is within 1 hour of the current time - proceed and generate the report. If not set at all (or it's not within 1 hour of the current time) then exit without running the report.
In production - don't set that config - and request the periodic job to run only at the interval on which you want the report to be generated. In PTE, have it installed to run more frequently but only generate the actual report through DbConfig. This way you can update code, set a DbConfig with the current time, and have a new result within 1 hour. Not on-demand, but closer to it.