Bug 30394

Summary: Add 'draw' handling to the datatables wrapper and REST API
Product: Koha Reporter: Tomás Cohen Arazi <tomascohen>
Component: Architecture, internals, and plumbingAssignee: Tomás Cohen Arazi <tomascohen>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: jonathan.druart, kyle, martin.renvoize
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30055
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30063
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00
Bug Depends on: 30393    
Bug Blocks: 30408    
Attachments: Bug 30394: Unit tests
Bug 30394: Add x-koha-request-id handling in controllers
Bug 30394: Add x-koha-request-id support on API routes
Bug 30394: Make datatables.js aware of x-koha-request-id
Bug 30394: Unit tests
Bug 30394: Add x-koha-request-id handling in controllers
Bug 30394: Add x-koha-request-id support on API routes
Bug 30394: Make datatables.js aware of x-koha-request-id
Bug 30394: Unit tests
Bug 30394: Add x-koha-request-id handling in controllers
Bug 30394: Add x-koha-request-id support on API routes
Bug 30394: Make datatables.js aware of x-koha-request-id
Bug 30408: Make API and OpenAPI versions strings in spec

Description Tomás Cohen Arazi 2022-03-29 10:58:07 UTC
A new header handling should be added so it is passed back and forth when requests are made. It should then be translated into/from the 'draw' parameter by the wrapper. We could name the headerr x-koha-request-id.
Comment 1 Tomás Cohen Arazi 2022-03-30 12:03:33 UTC
Created attachment 132576 [details] [review]
Bug 30394: Unit tests

This patch adds tests for checking the x-koha-request-id header is
returned on GET routes that have it enabled, and then the request
includes it.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/query.t
=> FAIL: The feature is not implemented, tests fail

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 2 Tomás Cohen Arazi 2022-03-30 12:03:36 UTC
Created attachment 132577 [details] [review]
Bug 30394: Add x-koha-request-id handling in controllers

This patch adds 'x-koha-request-id' to the reserved param names list,
and makes the objects.search helper read it and send it back in the
response headers.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 3 Tomás Cohen Arazi 2022-03-30 12:03:41 UTC
Created attachment 132578 [details] [review]
Bug 30394: Add x-koha-request-id support on API routes

This patch adds the x-koha-request-id to all GET routes that rely on
objects.search, for immediate support for the header.

The patch itself is trivial:
- It adds the header parameter definition to the top level swagger.yaml
- It adds a reference on each route that already implements q params,
  etc

To test:
1. Apply the patch
2. Reload plack
3. Notice the API still works
4. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/query.t
=> SUCCESS: It now passes! The /cities route implements the
x-koha-request-id header pass through.
5. Run the rest of the API tests
=> SUCCESS: All good
6. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 4 Tomás Cohen Arazi 2022-03-30 12:03:44 UTC
Created attachment 132579 [details] [review]
Bug 30394: Make datatables.js aware of x-koha-request-id

This patch makes the wrapper handle the data.draw parameter (from
DataTables) translating it into the x-koha-request-id header for making
the Koha request, and then translates the received header into data.draw
for proper use in DataTables.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 5 Jonathan Druart 2022-03-30 12:15:35 UTC
Created attachment 132582 [details] [review]
Bug 30394: Unit tests

This patch adds tests for checking the x-koha-request-id header is
returned on GET routes that have it enabled, and then the request
includes it.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/query.t
=> FAIL: The feature is not implemented, tests fail

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Jonathan Druart 2022-03-30 12:15:41 UTC
Created attachment 132583 [details] [review]
Bug 30394: Add x-koha-request-id handling in controllers

This patch adds 'x-koha-request-id' to the reserved param names list,
and makes the objects.search helper read it and send it back in the
response headers.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Jonathan Druart 2022-03-30 12:15:46 UTC
Created attachment 132584 [details] [review]
Bug 30394: Add x-koha-request-id support on API routes

This patch adds the x-koha-request-id to all GET routes that rely on
objects.search, for immediate support for the header.

The patch itself is trivial:
- It adds the header parameter definition to the top level swagger.yaml
- It adds a reference on each route that already implements q params,
  etc

To test:
1. Apply the patch
2. Reload plack
3. Notice the API still works
4. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/query.t
=> SUCCESS: It now passes! The /cities route implements the
x-koha-request-id header pass through.
5. Run the rest of the API tests
=> SUCCESS: All good
6. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Jonathan Druart 2022-03-30 12:15:51 UTC
Created attachment 132585 [details] [review]
Bug 30394: Make datatables.js aware of x-koha-request-id

This patch makes the wrapper handle the data.draw parameter (from
DataTables) translating it into the x-koha-request-id header for making
the Koha request, and then translates the received header into data.draw
for proper use in DataTables.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 9 Martin Renvoize 2022-03-30 12:41:16 UTC
Created attachment 132598 [details] [review]
Bug 30394: Unit tests

This patch adds tests for checking the x-koha-request-id header is
returned on GET routes that have it enabled, and then the request
includes it.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/query.t
=> FAIL: The feature is not implemented, tests fail

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 10 Martin Renvoize 2022-03-30 12:41:21 UTC
Created attachment 132599 [details] [review]
Bug 30394: Add x-koha-request-id handling in controllers

This patch adds 'x-koha-request-id' to the reserved param names list,
and makes the objects.search helper read it and send it back in the
response headers.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 11 Martin Renvoize 2022-03-30 12:41:26 UTC
Created attachment 132600 [details] [review]
Bug 30394: Add x-koha-request-id support on API routes

This patch adds the x-koha-request-id to all GET routes that rely on
objects.search, for immediate support for the header.

The patch itself is trivial:
- It adds the header parameter definition to the top level swagger.yaml
- It adds a reference on each route that already implements q params,
  etc

To test:
1. Apply the patch
2. Reload plack
3. Notice the API still works
4. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/query.t
=> SUCCESS: It now passes! The /cities route implements the
x-koha-request-id header pass through.
5. Run the rest of the API tests
=> SUCCESS: All good
6. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 12 Martin Renvoize 2022-03-30 12:41:31 UTC
Created attachment 132601 [details] [review]
Bug 30394: Make datatables.js aware of x-koha-request-id

This patch makes the wrapper handle the data.draw parameter (from
DataTables) translating it into the x-koha-request-id header for making
the Koha request, and then translates the received header into data.draw
for proper use in DataTables.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 13 Martin Renvoize 2022-03-30 12:41:37 UTC
Created attachment 132602 [details] [review]
Bug 30408: Make API and OpenAPI versions strings in spec

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 14 Martin Renvoize 2022-03-30 12:42:19 UTC
Another QA stamp never hurts.
Comment 15 Fridolin Somers 2022-04-05 15:29:17 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 16 Tomás Cohen Arazi 2022-05-08 13:22:47 UTC
This could actually be backported?