Bug 37639 - items.stack ( shelving control number ) not included in items API endpoint
Summary: items.stack ( shelving control number ) not included in items API endpoint
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Lucas Gass (lukeg)
QA Contact: Tomás Cohen Arazi (tcohen)
URL:
Keywords:
Depends on:
Blocks: 37637
  Show dependency treegraph
 
Reported: 2024-08-13 21:00 UTC by Lucas Gass (lukeg)
Modified: 2024-10-29 15:17 UTC (History)
6 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 37639: Add items.stack to items endpoint (1.54 KB, patch)
2024-08-13 21:03 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 37639: Add items.stack to items endpoint (1.56 KB, patch)
2024-08-14 19:24 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 37639: (follow-up) Remove stack from API mapping (923 bytes, patch)
2024-08-14 19:25 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 37639: Add items.stack to items endpoint (1.62 KB, patch)
2024-08-15 16:14 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 37639: (follow-up) Remove stack from API mapping (983 bytes, patch)
2024-08-15 16:14 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 37639: Add unit tests (6.41 KB, patch)
2024-08-16 16:01 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 37639: Map items.stack as shelving_control_number in API (1.37 KB, patch)
2024-08-27 20:01 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 37639: Adjust tests (1.47 KB, patch)
2024-10-18 14:43 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 37639: Adjust tests (11.60 KB, patch)
2024-10-18 16:28 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 37639: Add items.stack to items endpoint (1.66 KB, patch)
2024-10-29 11:13 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 37639: (follow-up) Remove redundant mappings from Koha::Item::to_api_mapping() (1.75 KB, patch)
2024-10-29 11:13 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Lucas Gass (lukeg) 2024-08-13 21:00:53 UTC
items.stack is not included at /api/v1/items/

I think it should be
Comment 1 Lucas Gass (lukeg) 2024-08-13 21:03:44 UTC
Created attachment 170299 [details] [review]
Bug 37639: Add items.stack to items endpoint

To test:
1. Apply patch and restart_all
2. Check the items endpoint for items.stack ( http://localhost:8081/api/v1/items/144 )
3. The data is there, and correct.
Comment 2 Lucas Gass (lukeg) 2024-08-14 19:24:00 UTC
Created attachment 170328 [details] [review]
Bug 37639: Add items.stack to items endpoint

To test:
1. Apply patch and restart_all, and yarn api:bundle
2. Check the items endpoint for items.stack ( http://localhost:8081/api/v1/items/144 )
3. The data is there, and correct.
Comment 3 Lucas Gass (lukeg) 2024-08-14 19:25:45 UTC
Created attachment 170329 [details] [review]
Bug 37639: (follow-up) Remove stack from API mapping

Shouldn't need to define stack in to_api_mapping because the name isn't changing.
Comment 4 Paul Derscheid 2024-08-15 16:14:35 UTC
Created attachment 170396 [details] [review]
Bug 37639: Add items.stack to items endpoint

To test:
1. Apply patch and restart_all, and yarn api:bundle
2. Check the items endpoint for items.stack ( http://localhost:8081/api/v1/items/144 )
3. The data is there, and correct.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 5 Paul Derscheid 2024-08-15 16:14:37 UTC
Created attachment 170397 [details] [review]
Bug 37639: (follow-up) Remove stack from API mapping

Shouldn't need to define stack in to_api_mapping because the name isn't changing.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 6 Paul Derscheid 2024-08-15 16:16:11 UTC
Why is items.stack the only column in items that doesn't have a comment in kohastructure.pl?
Comment 7 Lucas Gass (lukeg) 2024-08-15 17:52:24 UTC
(In reply to Paul Derscheid from comment #6)
> Why is items.stack the only column in items that doesn't have a comment in
> kohastructure.pl?

It's a good question. There should be more info. on what it is. I had to ask around to find out.

It is also one of the only ones without POD in Koha/Schema/Result/Item.pm
Comment 8 Lucas Gass (lukeg) 2024-08-15 19:14:32 UTC
(In reply to Paul Derscheid from comment #6)
> Why is items.stack the only column in items that doesn't have a comment in
> kohastructure.pl?

https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37653
Comment 9 Marcel de Rooy 2024-08-16 06:26:29 UTC
Just feeling that it would be better to list it (skip 2nd patch).
Also note:
        withdrawn                => 'withdrawn',
        timestamp                => 'timestamp',
        location                 => 'location',
        uri                      => 'uri',

Is it possible to add a tiny test to prove the result of this change?
Comment 10 Lucas Gass (lukeg) 2024-08-16 16:01:23 UTC
Created attachment 170458 [details] [review]
Bug 37639: Add unit tests
Comment 11 Lucas Gass (lukeg) 2024-08-16 16:03:26 UTC
> Is it possible to add a tiny test to prove the result of this change?

I don't know how to write a test for my change only, so I added some for all the to_api_mappiings in Item.pm
Comment 12 Martin Renvoize (ashimema) 2024-08-21 08:30:59 UTC
OK.. we add it to the mapping... As people are confused about 'stack'.. should we not actually map it to something more meaningful for the API field?

control_number perhaps?
Comment 13 Katrin Fischer 2024-08-21 13:22:12 UTC
(In reply to Martin Renvoize from comment #12)
> OK.. we add it to the mapping... As people are confused about 'stack'..
> should we not actually map it to something more meaningful for the API field?
> 
> control_number perhaps?

I think control_number might also be a bit difficult as it reminds of the MARC 001 label. shelving_control_number maybe?
Comment 14 Lucas Gass (lukeg) 2024-08-23 15:51:22 UTC
(In reply to Katrin Fischer from comment #13)
> (In reply to Martin Renvoize from comment #12)
> > OK.. we add it to the mapping... As people are confused about 'stack'..
> > should we not actually map it to something more meaningful for the API field?
> > 
> > control_number perhaps?
> 
> I think control_number might also be a bit difficult as it reminds of the
> MARC 001 label. shelving_control_number maybe?

I'm happy to change the patch. Is 'shelving_control_number' agreed upon?
Comment 15 Katrin Fischer 2024-08-23 15:54:45 UTC
I think Martin is not around for a few days. If you agree, maybe move on with it.
Comment 16 Paul Derscheid 2024-08-23 15:58:36 UTC
Sorry, but what exactly is this referring to?
Comment 17 Katrin Fischer 2024-08-23 15:59:57 UTC
Exposing items.stacks as shelving_control_number in the API (I believe).
Comment 18 Paul Derscheid 2024-08-23 16:03:53 UTC
Alright, I also think shelving_control_number sounds reasonable.
Comment 19 Martin Renvoize (ashimema) 2024-08-23 16:06:42 UTC
Sounds great to me.. it's a tiny ask but I think that would poke it into PQA for me ﷐[U+1F600]﷑
Comment 20 Lucas Gass (lukeg) 2024-08-27 20:01:30 UTC
Created attachment 170782 [details] [review]
Bug 37639: Map items.stack as shelving_control_number in API
Comment 21 Marcel de Rooy 2024-10-18 09:16:15 UTC
 WARN   t/db_dependent/api/v1/items.t
   WARN   tidiness
                The file is less tidy than before (bad/messy lines before: 180, now: 225)
Comment 22 Marcel de Rooy 2024-10-18 09:16:54 UTC
    #   Failed test 'items.stack is mapped as stack in to_api_mapping'
    #   at /usr/share/koha/t/db_dependent/api/v1/items.t line 63.
     #          got: 'shelving_control_number'
    #     expected: 'stack'
     # Looks like you failed 1 test of 46.

    #   Failed test 'SWAGGER3.2.2'
    #   at /usr/share/koha/t/db_dependent/api/v1/items.t line 143.
     #          got: '500'
    #     expected: '200'
     # Looks like you planned 15 tests but ran 5.
     # Looks like you failed 1 test of 5 run.
Comment 23 Lucas Gass (lukeg) 2024-10-18 14:42:07 UTC
(In reply to Marcel de Rooy from comment #21)
>  WARN   t/db_dependent/api/v1/items.t
>    WARN   tidiness
>                 The file is less tidy than before (bad/messy lines before:
> 180, now: 225)

My patchset doesn't touch these lines so I won't tidy.
Comment 24 Lucas Gass (lukeg) 2024-10-18 14:43:06 UTC
Created attachment 172980 [details] [review]
Bug 37639: Adjust tests
Comment 25 Marcel de Rooy 2024-10-18 15:11:59 UTC
(In reply to Lucas Gass (lukeg) from comment #23)
> (In reply to Marcel de Rooy from comment #21)
> >  WARN   t/db_dependent/api/v1/items.t
> >    WARN   tidiness
> >                 The file is less tidy than before (bad/messy lines before:
> > 180, now: 225)
> 
> My patchset doesn't touch these lines so I won't tidy.

What do you mean with these lines btw?
Qa tools counts messy lines and tell us that your patch introduces 225-180 = 45 messy lines.
The second patch adds 60+ lines to the test file. I suspect that all lines that are considered too long have been counted.

So why are you stating that you did not touch these lines?
Comment 26 Lucas Gass (lukeg) 2024-10-18 16:28:04 UTC
Created attachment 172988 [details] [review]
Bug 37639: Adjust tests
Comment 27 Lucas Gass (lukeg) 2024-10-18 16:29:20 UTC
(In reply to Marcel de Rooy from comment #25)
> (In reply to Lucas Gass (lukeg) from comment #23)
> > (In reply to Marcel de Rooy from comment #21)
> > >  WARN   t/db_dependent/api/v1/items.t
> > >    WARN   tidiness
> > >                 The file is less tidy than before (bad/messy lines before:
> > > 180, now: 225)
> > 
> > My patchset doesn't touch these lines so I won't tidy.
> 
> What do you mean with these lines btw?
> Qa tools counts messy lines and tell us that your patch introduces 225-180 =
> 45 messy lines.
> The second patch adds 60+ lines to the test file. I suspect that all lines
> that are considered too long have been counted.
> 
> So why are you stating that you did not touch these lines?

I tidied them.
Comment 28 Marcel de Rooy 2024-10-25 09:05:32 UTC
Looking here
Comment 29 Marcel de Rooy 2024-10-25 09:14:52 UTC
(In reply to Marcel de Rooy from comment #22)

>     #   Failed test 'SWAGGER3.2.2'
>     #   at /usr/share/koha/t/db_dependent/api/v1/items.t line 143.
>      #          got: '500'
>     #     expected: '200'
>      # Looks like you planned 15 tests but ran 5.
>      # Looks like you failed 1 test of 5 run.

Thanks for tidying.
This test still fails with me with new line numbers:

    #   Failed test 'SWAGGER3.2.2'
    #   at /usr/share/koha/t/db_dependent/api/v1/items.t line 191.
    #          got: '500'
    #     expected: '200'
     # Looks like you planned 15 tests but ran 5.
     # Looks like you failed 1 test of 5 run.

Seeing warns in the log like:
[WARN] OpenAPI >>> GET /api/v1/items [{"message":"Properties not allowed: shelving_control_number.","path":"\/body\/0"}
etc
Comment 30 Lucas Gass (lukeg) 2024-10-25 22:37:06 UTC
(In reply to Marcel de Rooy from comment #29)
> (In reply to Marcel de Rooy from comment #22)
> 
> >     #   Failed test 'SWAGGER3.2.2'
> >     #   at /usr/share/koha/t/db_dependent/api/v1/items.t line 143.
> >      #          got: '500'
> >     #     expected: '200'
> >      # Looks like you planned 15 tests but ran 5.
> >      # Looks like you failed 1 test of 5 run.
> 
> Thanks for tidying.
> This test still fails with me with new line numbers:
> 
>     #   Failed test 'SWAGGER3.2.2'
>     #   at /usr/share/koha/t/db_dependent/api/v1/items.t line 191.
>     #          got: '500'
>     #     expected: '200'
>      # Looks like you planned 15 tests but ran 5.
>      # Looks like you failed 1 test of 5 run.
> 
> Seeing warns in the log like:
> [WARN] OpenAPI >>> GET /api/v1/items [{"message":"Properties not allowed:
> shelving_control_number.","path":"\/body\/0"}
> etc

Hmmm, I cannot make this failure happen locally.
Comment 31 Marcel de Rooy 2024-10-28 09:35:56 UTC
(In reply to Lucas Gass (lukeg) from comment #30)
> (In reply to Marcel de Rooy from comment #29)
> > (In reply to Marcel de Rooy from comment #22)
> > 
> > >     #   Failed test 'SWAGGER3.2.2'
> > >     #   at /usr/share/koha/t/db_dependent/api/v1/items.t line 143.
> > >      #          got: '500'
> > >     #     expected: '200'
> > >      # Looks like you planned 15 tests but ran 5.
> > >      # Looks like you failed 1 test of 5 run.
> > 
> > Thanks for tidying.
> > This test still fails with me with new line numbers:
> > 
> >     #   Failed test 'SWAGGER3.2.2'
> >     #   at /usr/share/koha/t/db_dependent/api/v1/items.t line 191.
> >     #          got: '500'
> >     #     expected: '200'
> >      # Looks like you planned 15 tests but ran 5.
> >      # Looks like you failed 1 test of 5 run.
> > 
> > Seeing warns in the log like:
> > [WARN] OpenAPI >>> GET /api/v1/items [{"message":"Properties not allowed:
> > shelving_control_number.","path":"\/body\/0"}
> > etc
> 
> Hmmm, I cannot make this failure happen locally.

Maybe someone else can check too ?
Comment 32 Tomás Cohen Arazi (tcohen) 2024-10-29 11:05:19 UTC
(In reply to Marcel de Rooy from comment #29)
> This test still fails with me with new line numbers:
> 
>     #   Failed test 'SWAGGER3.2.2'
>     #   at /usr/share/koha/t/db_dependent/api/v1/items.t line 191.
>     #          got: '500'
>     #     expected: '200'
>      # Looks like you planned 15 tests but ran 5.
>      # Looks like you failed 1 test of 5 run.
> 
> Seeing warns in the log like:
> [WARN] OpenAPI >>> GET /api/v1/items [{"message":"Properties not allowed:
> shelving_control_number.","path":"\/body\/0"}

You were missing the API spec bundle step:

```shell
yarn api:bundle
```
Comment 33 Tomás Cohen Arazi (tcohen) 2024-10-29 11:07:25 UTC
Lucas, I think there's been some miscommunication regarding this comment:

(In reply to Marcel de Rooy from comment #9)
> Just feeling that it would be better to list it (skip 2nd patch).
> Also note:
>         withdrawn                => 'withdrawn',
>         timestamp                => 'timestamp',
>         location                 => 'location',
>         uri                      => 'uri',
> 
> Is it possible to add a tiny test to prove the result of this change?

We never add tests for `to_api_mapping()` and my interpretation of Marcel's comment is that he doubts we need those specific mappings (which are dated a few years ago). I think we need to remove the tests and squash the patches.
Comment 34 Tomás Cohen Arazi (tcohen) 2024-10-29 11:13:00 UTC
Created attachment 173615 [details] [review]
Bug 37639: Add items.stack to items endpoint

To test:
1. Apply patch and restart_all, and yarn api:bundle
2. Check the items endpoint for items.stack ( http://localhost:8081/api/v1/items/144 )
3. The data is there, and correct.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Comment 35 Tomás Cohen Arazi (tcohen) 2024-10-29 11:13:03 UTC
Created attachment 173616 [details] [review]
Bug 37639: (follow-up) Remove redundant mappings from Koha::Item::to_api_mapping()

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 36 Katrin Fischer 2024-10-29 15:17:56 UTC
Pushed for 24.11!

Well done everyone, thank you!