https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42720

--- Comment #1 from Kyle M Hall (khall) <[email protected]> ---
Created attachment 202840
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202840&action=edit
Bug 42720: Add REST API endpoints to run a saved report and fetch its results

We should have equivalent functionality to svc/report in the REST API.
This patch adds the staff endpoints.

POST /reports/{report_id}/run runs a saved SQL report. A foreground run
returns the rows synchronously, capped by SvcMaxReportRows, in the same
shape as svc/report ( positional arrays, or column-keyed objects when
annotated is set ). A background run enqueues a Koha::BackgroundJob::RunReport
and returns 202 Accepted with a results URL to poll.

GET /reports/job/{job_id}/results is the deferred twin of a foreground
run: it returns the rows once the job has finished, 202 while the job is
still queued or running, and the same 400 a foreground run gives if the
job failed. There is deliberately no separate status endpoint, the
generic GET /jobs/{job_id} already provides job status, so adding one
under /reports would just duplicate it.

Running in the foreground needs execute_reports_foreground, and in the
background execute_reports_background. The logic is shared so the public
endpoints added next can reuse it via the is_public stash flag.

Test Plan:
1) Apply this patch
2) Restart all the things!
3) Enable the RESTBasicAuth system preference
4) Create a SQL report, e.g. SELECT 1 AS one, 2 AS two
5) curl -X POST http://localhost:8081/api/v1/reports/<id>/run \
     -u koha:koha -H 'Content-Type: application/json' \
     -d '{"run_type":"foreground"}'
6) Note the rows are returned as [[1,2]]!
7) Repeat with {"run_type":"foreground","annotated":true}
8) Note the rows are now keyed by column name!
9) Repeat with {"run_type":"background"}
10) Note you get a 202 with a job_id and a results_url!
11) curl the results_url
12) Note you get the rows once the job finishes!

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to