Bug 37856 - Some SUSHI providers require the platform parameter
Summary: Some SUSHI providers require the platform parameter
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: ERM (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Pedro Amorim
QA Contact: Testopia
URL:
Keywords: additional_work_needed, rel_23_11_candidate, rel_24_05_candidate
: 37058 (view as bug list)
Depends on: 37963
Blocks: 37526
  Show dependency treegraph
 
Reported: 2024-09-06 11:27 UTC by Pedro Amorim
Modified: 2024-10-04 08:34 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00
Circulation function:


Attachments
Bug 37856: [DONT PUSH] dbic changes (1.48 KB, patch)
2024-09-18 16:14 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 37856: Append platform parameter to SUSHI url if defined (929 bytes, patch)
2024-09-18 16:14 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 37856: atomicupdate (1.39 KB, patch)
2024-09-18 16:14 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 37856: Add service_platform field (4.56 KB, patch)
2024-09-18 16:14 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 37856: Consider 'Exceptions' not being part of 'Report_Header' (1.51 KB, patch)
2024-09-19 14:25 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 37856: Consider absence of 'Report_Items' (1008 bytes, patch)
2024-09-19 14:25 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 37856: Add tests (4.70 KB, patch)
2024-09-19 14:25 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 37856: [DONT PUSH] dbic changes (1.53 KB, patch)
2024-09-23 20:09 UTC, David Nind
Details | Diff | Splinter Review
Bug 37856: Append platform parameter to SUSHI url if defined (977 bytes, patch)
2024-09-23 20:09 UTC, David Nind
Details | Diff | Splinter Review
Bug 37856: atomicupdate (1.44 KB, patch)
2024-09-23 20:09 UTC, David Nind
Details | Diff | Splinter Review
Bug 37856: Add service_platform field (4.61 KB, patch)
2024-09-23 20:09 UTC, David Nind
Details | Diff | Splinter Review
Bug 37856: Consider 'Exceptions' not being part of 'Report_Header' (1.56 KB, patch)
2024-09-23 20:09 UTC, David Nind
Details | Diff | Splinter Review
Bug 37856: Consider absence of 'Report_Items' (1.03 KB, patch)
2024-09-23 20:09 UTC, David Nind
Details | Diff | Splinter Review
Bug 37856: Add tests (4.75 KB, patch)
2024-09-23 20:09 UTC, David Nind
Details | Diff | Splinter Review
Bug 37856: [DONT PUSH] dbic changes (1.53 KB, patch)
2024-09-26 19:21 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 37856: Append platform parameter to SUSHI url if defined (979 bytes, patch)
2024-09-26 19:22 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 37856: atomicupdate (1.44 KB, patch)
2024-09-26 19:22 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 37856: Add service_platform field (4.62 KB, patch)
2024-09-26 19:22 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 37856: Consider 'Exceptions' not being part of 'Report_Header' (1.56 KB, patch)
2024-09-26 19:22 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 37856: Consider absence of 'Report_Items' (1.03 KB, patch)
2024-09-26 19:22 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 37856: Add tests (4.77 KB, patch)
2024-09-26 19:22 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 37856: (QA follow-up) Tidy (7.97 KB, patch)
2024-09-26 19:22 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 37856: Fix existing test (1.13 KB, patch)
2024-09-27 18:43 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 37856: Add new test to test platform is correctly added to build_url (2.27 KB, patch)
2024-09-27 18:43 UTC, Pedro Amorim
Details | Diff | Splinter Review
Bug 37856: Update atomicupdate messages (2.18 KB, patch)
2024-09-30 08:30 UTC, Pedro Amorim
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Amorim 2024-09-06 11:27:34 UTC
The harvest_sushi method produces the following URL when harvesting SUSHI data:
<provider_url>/reports/<report_type>?customer_id=<customer_id>&requestor_id=<requestor_id>&api_key=<api_key>&begin_date=<begin_date>&end_date=<end_date>

Some providers require the 'platform' parameter. Docs here:
https://app.swaggerhub.com/apis/COUNTER/counter-sushi_5_0_api/5.0.2#/default/getReportsPR

We need to look for a way to identify when/if a provider requires this parameter, and add it to the URL if so.

The provider in question is ScienceDirect:
https://registry.countermetrics.org/platform/ab4d3560-1165-491d-a67e-9359d02c2a96

The 'platform parameter required' entry is unchecked even though this provider requires it. We should consider using this to identify if the parameter is required or not.
Comment 1 Pedro Amorim 2024-09-18 16:14:08 UTC
Created attachment 171680 [details] [review]
Bug 37856: [DONT PUSH] dbic changes
Comment 2 Pedro Amorim 2024-09-18 16:14:11 UTC
Created attachment 171681 [details] [review]
Bug 37856: Append platform parameter to SUSHI url if defined
Comment 3 Pedro Amorim 2024-09-18 16:14:14 UTC
Created attachment 171682 [details] [review]
Bug 37856: atomicupdate
Comment 4 Pedro Amorim 2024-09-18 16:14:17 UTC
Created attachment 171683 [details] [review]
Bug 37856: Add service_platform field

The change from this patch itself should be self-explanatory.
Testing for this requires credentials to a specific provider.
But the parameter is only added to the URL if defined.

Test plan, ktd, apply patch, run:
$ yarn js:build
$ yarn api:bundle
$ koha-plack --restart kohadev

1) Enable ERMModule
2) Create a new provider, visit:
<staff_url>/cgi-bin/koha/erm/eusage/usage_data_providers/add
3) Ensure 'Service platform' now shows. Create the provider and put something in this field.
4) View the provider, ensure the field is shown, visit:
<staff_url>/cgi-bin/koha/erm/eusage/usage_data_providers/1

Ensure all tests are still passing:
$ cypress run --spec t/cypress/integration/ERM/DataProviders_spec.ts
$ prove t/db_dependent/api/v1/erm_usage_*
Comment 5 Pedro Amorim 2024-09-19 14:25:52 UTC
Created attachment 171773 [details] [review]
Bug 37856: Consider 'Exceptions' not being part of 'Report_Header'

When fixing the issue around the missing platform parameter, we
noticed this particular provider also returns 'Exceptions' as
its own thing, not part of 'Report_Header', despite documentation:
https://countermetrics.stoplight.io/docs/counter-sushi-api/7cp0h7n1hm2en-tr-j1-journal-requests-controlled

From the link above, search for 'Exceptions'. Notice it should be under 'Report_Header'.
Either way, this patch accounts for this possibility.
Comment 6 Pedro Amorim 2024-09-19 14:25:55 UTC
Created attachment 171774 [details] [review]
Bug 37856: Consider absence of 'Report_Items'

The SUSHI provider in question for this patchset also does not return any
Report_Items entry. This patch accounts for that.
Comment 7 Pedro Amorim 2024-09-19 14:25:58 UTC
Created attachment 171775 [details] [review]
Bug 37856: Add tests

This is using the groundwork from bug 37963.
This is testing the specific error this bug is addressing:
Required parameter Platform is missing

It is also testing that the error message is correctly shown as a background
job report message to the user

Test plan:
prove t/db_dependent/Koha/BackgroundJob/ErmSushiHarvester.t
Comment 8 David Nind 2024-09-23 20:09:00 UTC
Created attachment 171893 [details] [review]
Bug 37856: [DONT PUSH] dbic changes

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 David Nind 2024-09-23 20:09:04 UTC
Created attachment 171894 [details] [review]
Bug 37856: Append platform parameter to SUSHI url if defined

Signed-off-by: David Nind <david@davidnind.com>
Comment 10 David Nind 2024-09-23 20:09:07 UTC
Created attachment 171895 [details] [review]
Bug 37856: atomicupdate

Signed-off-by: David Nind <david@davidnind.com>
Comment 11 David Nind 2024-09-23 20:09:10 UTC
Created attachment 171896 [details] [review]
Bug 37856: Add service_platform field

The change from this patch itself should be self-explanatory.
Testing for this requires credentials to a specific provider.
But the parameter is only added to the URL if defined.

Test plan, ktd, apply patch, run:
$ yarn js:build
$ yarn api:bundle
$ koha-plack --restart kohadev

1) Enable ERMModule
2) Create a new provider, visit:
<staff_url>/cgi-bin/koha/erm/eusage/usage_data_providers/add
3) Ensure 'Service platform' now shows. Create the provider and put something in this field.
4) View the provider, ensure the field is shown, visit:
<staff_url>/cgi-bin/koha/erm/eusage/usage_data_providers/1

Ensure all tests are still passing:
$ cypress run --spec t/cypress/integration/ERM/DataProviders_spec.ts
$ prove t/db_dependent/api/v1/erm_usage_*

Signed-off-by: David Nind <david@davidnind.com>
Comment 12 David Nind 2024-09-23 20:09:13 UTC
Created attachment 171897 [details] [review]
Bug 37856: Consider 'Exceptions' not being part of 'Report_Header'

When fixing the issue around the missing platform parameter, we
noticed this particular provider also returns 'Exceptions' as
its own thing, not part of 'Report_Header', despite documentation:
https://countermetrics.stoplight.io/docs/counter-sushi-api/7cp0h7n1hm2en-tr-j1-journal-requests-controlled

From the link above, search for 'Exceptions'. Notice it should be under 'Report_Header'.
Either way, this patch accounts for this possibility.

Signed-off-by: David Nind <david@davidnind.com>
Comment 13 David Nind 2024-09-23 20:09:16 UTC
Created attachment 171898 [details] [review]
Bug 37856: Consider absence of 'Report_Items'

The SUSHI provider in question for this patchset also does not return any
Report_Items entry. This patch accounts for that.

Signed-off-by: David Nind <david@davidnind.com>
Comment 14 David Nind 2024-09-23 20:09:19 UTC
Created attachment 171899 [details] [review]
Bug 37856: Add tests

This is using the groundwork from bug 37963.
This is testing the specific error this bug is addressing:
Required parameter Platform is missing

It is also testing that the error message is correctly shown as a background
job report message to the user

Test plan:
prove t/db_dependent/Koha/BackgroundJob/ErmSushiHarvester.t

Signed-off-by: David Nind <david@davidnind.com>
Comment 15 David Nind 2024-09-23 20:18:01 UTC
I've signed off, but wasn't really able to test steps 3 and 4 for the 'Add service_platform' patch, and the 'Consider 'Exceptions' not being part of 'Report_Header'' patch.

The tests all pass, and as I understand it the tests mock these.

Testing notes (using KTD):

1. Run databaseupdate and restart_all, after applying the patches and running yarn js:build and yarn api:bundle.
Comment 16 Nick Clemens (kidclamp) 2024-09-26 19:21:58 UTC
Created attachment 172040 [details] [review]
Bug 37856: [DONT PUSH] dbic changes

Signed-off-by: David Nind <david@davidnind.com>
Comment 17 Nick Clemens (kidclamp) 2024-09-26 19:22:01 UTC
Created attachment 172042 [details] [review]
Bug 37856: Append platform parameter to SUSHI url if defined

Signed-off-by: David Nind <david@davidnind.com>
Comment 18 Nick Clemens (kidclamp) 2024-09-26 19:22:03 UTC
Created attachment 172043 [details] [review]
Bug 37856: atomicupdate

Signed-off-by: David Nind <david@davidnind.com>
Comment 19 Nick Clemens (kidclamp) 2024-09-26 19:22:06 UTC
Created attachment 172044 [details] [review]
Bug 37856: Add service_platform field

The change from this patch itself should be self-explanatory.
Testing for this requires credentials to a specific provider.
But the parameter is only added to the URL if defined.

Test plan, ktd, apply patch, run:
$ yarn js:build
$ yarn api:bundle
$ koha-plack --restart kohadev

1) Enable ERMModule
2) Create a new provider, visit:
<staff_url>/cgi-bin/koha/erm/eusage/usage_data_providers/add
3) Ensure 'Service platform' now shows. Create the provider and put something in this field.
4) View the provider, ensure the field is shown, visit:
<staff_url>/cgi-bin/koha/erm/eusage/usage_data_providers/1

Ensure all tests are still passing:
$ cypress run --spec t/cypress/integration/ERM/DataProviders_spec.ts
$ prove t/db_dependent/api/v1/erm_usage_*

Signed-off-by: David Nind <david@davidnind.com>
Comment 20 Nick Clemens (kidclamp) 2024-09-26 19:22:08 UTC
Created attachment 172045 [details] [review]
Bug 37856: Consider 'Exceptions' not being part of 'Report_Header'

When fixing the issue around the missing platform parameter, we
noticed this particular provider also returns 'Exceptions' as
its own thing, not part of 'Report_Header', despite documentation:
https://countermetrics.stoplight.io/docs/counter-sushi-api/7cp0h7n1hm2en-tr-j1-journal-requests-controlled

From the link above, search for 'Exceptions'. Notice it should be under 'Report_Header'.
Either way, this patch accounts for this possibility.

Signed-off-by: David Nind <david@davidnind.com>
Comment 21 Nick Clemens (kidclamp) 2024-09-26 19:22:10 UTC
Created attachment 172046 [details] [review]
Bug 37856: Consider absence of 'Report_Items'

The SUSHI provider in question for this patchset also does not return any
Report_Items entry. This patch accounts for that.

Signed-off-by: David Nind <david@davidnind.com>
Comment 22 Nick Clemens (kidclamp) 2024-09-26 19:22:13 UTC
Created attachment 172047 [details] [review]
Bug 37856: Add tests

This is using the groundwork from bug 37963.
This is testing the specific error this bug is addressing:
Required parameter Platform is missing

It is also testing that the error message is correctly shown as a background
job report message to the user

Test plan:
prove t/db_dependent/Koha/BackgroundJob/ErmSushiHarvester.t

Signed-off-by: David Nind <david@davidnind.com>
Comment 23 Nick Clemens (kidclamp) 2024-09-26 19:22:15 UTC
Created attachment 172048 [details] [review]
Bug 37856: (QA follow-up) Tidy
Comment 24 Pedro Amorim 2024-09-27 09:58:28 UTC
Thanks for QA, Nick.
Adding 24.05 and 23.11 release candidate keywords as this improves how the SUSHI response is handled widening the pool of providers Koha is able to work with.
Comment 25 Katrin Fischer 2024-09-27 15:56:17 UTC
The way the database update outputs messages is a bit non-standard. I fixed the messages (we are not mentioning the bug number every time for example), but I didn't change the structure.
I think what it should have done was printing different messages in case of the column already existing or not, but the "Done" seems not quite right.
Not terribly important overall, just noting for future.
Comment 26 Katrin Fischer 2024-09-27 17:41:27 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 27 Pedro Amorim 2024-09-27 18:43:14 UTC
Created attachment 172155 [details] [review]
Bug 37856: Fix existing test

A service_platform value was being randomly to 'service_platform' as is a new attribute.
Assign undef to that to fix existing test
Comment 28 Pedro Amorim 2024-09-27 18:43:17 UTC
Created attachment 172156 [details] [review]
Bug 37856: Add new test to test platform is correctly added to build_url

prove t/db\_dependent/Koha/ERM/EUsage/UsageDataProvider.t
Comment 29 Pedro Amorim 2024-09-27 18:44:05 UTC
Added 2 follow-up test patches to fix existing tests and add a new one. Adding additional_work_needed keyword to notify Katrin of these 2 follow-ups.
Comment 30 Jonathan Druart 2024-09-30 08:04:59 UTC
19         say_success( $out, "Done" );

Is this expected? "Done"?
Comment 31 Pedro Amorim 2024-09-30 08:30:45 UTC
Created attachment 172215 [details] [review]
Bug 37856: Update atomicupdate messages

(In reply to Katrin Fischer from comment #25)
> The way the database update outputs messages is a bit non-standard. I fixed
> the messages (we are not mentioning the bug number every time for example),
> but I didn't change the structure.
> I think what it should have done was printing different messages in case of
> the column already existing or not, but the "Done" seems not quite right.
> Not terribly important overall, just noting for future.

(In reply to Jonathan Druart from comment #30)
> 19         say_success( $out, "Done" );
>
> Is this expected? "Done"?

The original patch:
https://github.com/Koha-Community/Koha/commit/2e4b1ca42f7a940e8329ed860dda102deb629db0#diff-661419b80761834f79ce9100a1f2a132b804ee7cdf4efffe14c29d93bec810e4R17

Had:
say_success( $out, "Bug 37856 - Done" );

I wanted to provide indication that the update of that particular bug was done, regardless if a change on the database happened or not.
This is clearly causing confusion, this is now showing messages more in line with standard I believe.
Comment 32 Pedro Amorim 2024-10-04 08:34:25 UTC
*** Bug 37058 has been marked as a duplicate of this bug. ***