<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>A new request with request id 8072 has been created by koha-devel-request@lists.koha-community.org. Short info on the request is : <br><br>Title : Koha-devel Digest, Vol 201, Issue 9<br>Category : <br>Description : <div>Send Koha-devel mailing list submissions to<br>    koha-devel@lists.koha-community.org<br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>    https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>or, via email, send a message with subject or body 'help' to<br>    koha-devel-request@lists.koha-community.org<br><br>You can reach the person managing the list at<br>    koha-devel-owner@lists.koha-community.org<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Koha-devel digest..."<br><br><br>Today's Topics:<br><br>   1. Re: Getting "count" when using REST API (Renvoize, Martin)<br>   2. Re: Getting "count" when using REST API (Tomas Cohen Arazi)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Fri, 5 Aug 2022 15:42:29 +0100<br>From: "Renvoize, Martin" <martin.renvoize@ptfs-europe.com><br>To: dcook@prosentient.com.au<br>Cc: Tomas Cohen Arazi <tomascohen@gmail.com>, Koha Devel<br>    <koha-devel@lists.koha-community.org>,  Jonathan Druart<br>    <jonathan.druart@gmail.com><br>Subject: Re: [Koha-devel] Getting "count" when using REST API<br>Message-ID:<br>    <CAB7SL8DSQ6yHF5PKjQbPwaHo2cQxHWLVmAOoB1kij_KNhd_FtA@mail.gmail.com><br>Content-Type: text/plain; charset="utf-8"<br><br>We should probably implement this as a HEAD request.. i.e. instead of doing<br>a special ?_page=1&_per_page=1, we should just allow requesting the HEAD on<br>whatever the request was and then you can read the X-Total-Count header..<br>in the Koha side we can handle such a request with performance in mind and<br>not both fetching all the data to return etc.<br><br>*Martin Renvoize, MPhys (Hons)*<br><br><https://www.ptfs-europe.com><br><br>Head of Development and Community Engagement<br><br><br><br>*Phone:* +44 (0) 1483 378728<br><br>*Mobile:* +44 (0) 7725 985 636<br><br>*Email:* martin.renvoize@ptfs-europe.com<br><br>www.ptfs-europe.com<br><br><br>*Sign up for our newsletters here <http://eepurl.com/dPjjkn> or by scanning<br>the QR code*<br><br><br><br>Registered in the United Kingdom No. 06416372   VAT Reg No. 925 7211 30<br><br>The information contained in this email message may be privileged,<br>confidential and protected from disclosure. If you are not the intended<br>recipient, any dissemination, distribution or copying is strictly<br>prohibited. If you think that you have received this email message in<br>error, please email the sender at info@ptfs-europe.com<br><br><br>On Fri, 5 Aug 2022 at 01:31, <dcook@prosentient.com.au> wrote:<br><br>> How do you mean?<br>><br>><br>><br>> In my case, I’m improving how my Keycloak User Storage extension works<br>> with Koha. It fetches the count of users and then sends an API request<br>> using an offset and that count to handle the paging. Their internal API<br>> breaks it into 2 steps, so I have to hit the database twice anyway.<br>><br>><br>><br>> David Cook<br>><br>> Senior Software Engineer<br>><br>> Prosentient Systems<br>><br>> Suite 7.03<br>><br>> 6a Glen St<br>><br>> Milsons Point NSW 2061<br>><br>> Australia<br>><br>><br>><br>> Office: 02 9212 0899<br>><br>> Online: 02 8005 0595<br>><br>><br>><br>> *From:* Tomas Cohen Arazi <tomascohen@gmail.com><br>> *Sent:* Friday, 5 August 2022 10:26 AM<br>> *To:* David Cook <dcook@prosentient.com.au><br>> *Cc:* Jonathan Druart <jonathan.druart@gmail.com>; Koha Devel <<br>> koha-devel@lists.koha-community.org><br>> *Subject:* Re: [Koha-devel] Getting "count" when using REST API<br>><br>><br>><br>> That's a smart trick!<br>><br>><br>><br>> We should not be lazy though, and add a generic way to retrieve the count<br>> without making several DB hits.<br>><br>><br>><br>> El jue, 4 ago 2022 20:56, <dcook@prosentient.com.au> escribió:<br>><br>> Jonathan, you are a champion! That'll work perfectly for me!<br>><br>> David Cook<br>> Senior Software Engineer<br>> Prosentient Systems<br>> Suite 7.03<br>> 6a Glen St<br>> Milsons Point NSW 2061<br>> Australia<br>><br>> Office: 02 9212 0899<br>> Online: 02 8005 0595<br>><br>> -----Original Message-----<br>> From: Jonathan Druart <jonathan.druart@gmail.com><br>> Sent: Thursday, 4 August 2022 10:17 PM<br>> To: Tomas Cohen Arazi <tomascohen@gmail.com><br>> Cc: David Cook <dcook@prosentient.com.au>; Koha Devel <<br>> koha-devel@lists.koha-community.org><br>> Subject: Re: [Koha-devel] Getting "count" when using REST API<br>><br>>  I needed that for ERM and I did a GET with _page=1 and _per_page=1 (to<br>> retrieve only 1 result) then read the X-Total-Count value from the header's<br>> response ;)<br>><br>> Le jeu. 4 août 2022 à 12:33, Tomas Cohen Arazi <tomascohen@gmail.com> a<br>> écrit :<br>> ><br>> > Only with x-koha-embed<br>> ><br>> ><br>> > El jue, 4 ago 2022 3:54, <dcook@prosentient.com.au> escribió:<br>> >><br>> >> Hi all,<br>> >><br>> >><br>> >><br>> >> Is there a method for getting a “count” using the REST API without<br>> fetching every record?<br>> >><br>> >><br>> >><br>> >> When building a paging lookup outside of Koha, it would be useful to<br>> get a total record count and then just fetch the page of records that you<br>> need.<br>> >><br>> >><br>> >><br>> >> Thanks!<br>> >><br>> >><br>> >><br>> >> David Cook<br>> >><br>> >> Senior Software Engineer<br>> >><br>> >> Prosentient Systems<br>> >><br>> >> Suite 7.03<br>> >><br>> >> 6a Glen St<br>> >><br>> >> Milsons Point NSW 2061<br>> >><br>> >> Australia<br>> >><br>> >><br>> >><br>> >> Office: 02 9212 0899<br>> >><br>> >> Online: 02 8005 0595<br>> >><br>> >><br>> ><br>> > _______________________________________________<br>> > Koha-devel mailing list<br>> > Koha-devel@lists.koha-community.org<br>> > https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>> > website : https://www.koha-community.org/ git :<br>> > https://git.koha-community.org/ bugs :<br>> > https://bugs.koha-community.org/<br>><br>> _______________________________________________<br>> Koha-devel mailing list<br>> Koha-devel@lists.koha-community.org<br>> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>> website : https://www.koha-community.org/<br>> git : https://git.koha-community.org/<br>> bugs : https://bugs.koha-community.org/<br>><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20220805/01889cfd/attachment-0001.htm><br><br>------------------------------<br><br>Message: 2<br>Date: Fri, 5 Aug 2022 12:15:04 -0300<br>From: Tomas Cohen Arazi <tomascohen@gmail.com><br>To: "Renvoize, Martin" <martin.renvoize@ptfs-europe.com><br>Cc: David Cook <dcook@prosentient.com.au>,  Koha Devel<br>    <koha-devel@lists.koha-community.org>,  Jonathan Druart<br>    <jonathan.druart@gmail.com><br>Subject: Re: [Koha-devel] Getting "count" when using REST API<br>Message-ID:<br>    <CABZfb=WE8MT+5n4OO8EfDr0zAU7yDmd+e8kUu48oE4bQU4YzxQ@mail.gmail.com><br>Content-Type: text/plain; charset="utf-8"<br><br>I'll file a bug for that. I'm thinking we could reconsider the return value<br>for objects.search at this point (i.e. just return the resultset and let<br>the controller call ->to_api). It feels it would be more consistent too.<br><br>Nice one!<br><br>El vie, 5 ago 2022 11:42, Renvoize, Martin <martin.renvoize@ptfs-europe.com><br>escribió:<br><br>> We should probably implement this as a HEAD request.. i.e. instead of<br>> doing a special ?_page=1&_per_page=1, we should just allow requesting the<br>> HEAD on whatever the request was and then you can read the X-Total-Count<br>> header.. in the Koha side we can handle such a request with performance in<br>> mind and not both fetching all the data to return etc.<br>><br>> *Martin Renvoize, MPhys (Hons)*<br>><br>> <https://www.ptfs-europe.com><br>><br>> Head of Development and Community Engagement<br>><br>><br>><br>> *Phone:* +44 (0) 1483 378728<br>><br>> *Mobile:* +44 (0) 7725 985 636<br>><br>> *Email:* martin.renvoize@ptfs-europe.com<br>><br>> www.ptfs-europe.com<br>><br>><br>> *Sign up for our newsletters here <http://eepurl.com/dPjjkn> or by<br>> scanning the QR code*<br>><br>><br>><br>> Registered in the United Kingdom No. 06416372   VAT Reg No. 925 7211 30<br>><br>> The information contained in this email message may be privileged,<br>> confidential and protected from disclosure. If you are not the intended<br>> recipient, any dissemination, distribution or copying is strictly<br>> prohibited. If you think that you have received this email message in<br>> error, please email the sender at info@ptfs-europe.com<br>><br>><br>> On Fri, 5 Aug 2022 at 01:31, <dcook@prosentient.com.au> wrote:<br>><br>>> How do you mean?<br>>><br>>><br>>><br>>> In my case, I’m improving how my Keycloak User Storage extension works<br>>> with Koha. It fetches the count of users and then sends an API request<br>>> using an offset and that count to handle the paging. Their internal API<br>>> breaks it into 2 steps, so I have to hit the database twice anyway.<br>>><br>>><br>>><br>>> David Cook<br>>><br>>> Senior Software Engineer<br>>><br>>> Prosentient Systems<br>>><br>>> Suite 7.03<br>>><br>>> 6a Glen St<br>>><br>>> Milsons Point NSW 2061<br>>><br>>> Australia<br>>><br>>><br>>><br>>> Office: 02 9212 0899<br>>><br>>> Online: 02 8005 0595<br>>><br>>><br>>><br>>> *From:* Tomas Cohen Arazi <tomascohen@gmail.com><br>>> *Sent:* Friday, 5 August 2022 10:26 AM<br>>> *To:* David Cook <dcook@prosentient.com.au><br>>> *Cc:* Jonathan Druart <jonathan.druart@gmail.com>; Koha Devel <<br>>> koha-devel@lists.koha-community.org><br>>> *Subject:* Re: [Koha-devel] Getting "count" when using REST API<br>>><br>>><br>>><br>>> That's a smart trick!<br>>><br>>><br>>><br>>> We should not be lazy though, and add a generic way to retrieve the count<br>>> without making several DB hits.<br>>><br>>><br>>><br>>> El jue, 4 ago 2022 20:56, <dcook@prosentient.com.au> escribió:<br>>><br>>> Jonathan, you are a champion! That'll work perfectly for me!<br>>><br>>> David Cook<br>>> Senior Software Engineer<br>>> Prosentient Systems<br>>> Suite 7.03<br>>> 6a Glen St<br>>> Milsons Point NSW 2061<br>>> Australia<br>>><br>>> Office: 02 9212 0899<br>>> Online: 02 8005 0595<br>>><br>>> -----Original Message-----<br>>> From: Jonathan Druart <jonathan.druart@gmail.com><br>>> Sent: Thursday, 4 August 2022 10:17 PM<br>>> To: Tomas Cohen Arazi <tomascohen@gmail.com><br>>> Cc: David Cook <dcook@prosentient.com.au>; Koha Devel <<br>>> koha-devel@lists.koha-community.org><br>>> Subject: Re: [Koha-devel] Getting "count" when using REST API<br>>><br>>>  I needed that for ERM and I did a GET with _page=1 and _per_page=1 (to<br>>> retrieve only 1 result) then read the X-Total-Count value from the header's<br>>> response ;)<br>>><br>>> Le jeu. 4 août 2022 à 12:33, Tomas Cohen Arazi <tomascohen@gmail.com> a<br>>> écrit :<br>>> ><br>>> > Only with x-koha-embed<br>>> ><br>>> ><br>>> > El jue, 4 ago 2022 3:54, <dcook@prosentient.com.au> escribió:<br>>> >><br>>> >> Hi all,<br>>> >><br>>> >><br>>> >><br>>> >> Is there a method for getting a “count” using the REST API without<br>>> fetching every record?<br>>> >><br>>> >><br>>> >><br>>> >> When building a paging lookup outside of Koha, it would be useful to<br>>> get a total record count and then just fetch the page of records that you<br>>> need.<br>>> >><br>>> >><br>>> >><br>>> >> Thanks!<br>>> >><br>>> >><br>>> >><br>>> >> David Cook<br>>> >><br>>> >> Senior Software Engineer<br>>> >><br>>> >> Prosentient Systems<br>>> >><br>>> >> Suite 7.03<br>>> >><br>>> >> 6a Glen St<br>>> >><br>>> >> Milsons Point NSW 2061<br>>> >><br>>> >> Australia<br>>> >><br>>> >><br>>> >><br>>> >> Office: 02 9212 0899<br>>> >><br>>> >> Online: 02 8005 0595<br>>> >><br>>> >><br>>> ><br>>> > _______________________________________________<br>>> > Koha-devel mailing list<br>>> > Koha-devel@lists.koha-community.org<br>>> > https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>>> > website : https://www.koha-community.org/ git :<br>>> > https://git.koha-community.org/ bugs :<br>>> > https://bugs.koha-community.org/<br>>><br>>> _______________________________________________<br>>> Koha-devel mailing list<br>>> Koha-devel@lists.koha-community.org<br>>> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>>> website : https://www.koha-community.org/<br>>> git : https://git.koha-community.org/<br>>> bugs : https://bugs.koha-community.org/<br>>><br>><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20220805/51f6af90/attachment.htm><br><br>------------------------------<br><br>Subject: Digest Footer<br><br>_______________________________________________<br>Koha-devel mailing list<br>Koha-devel@lists.koha-community.org<br>https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel<br>website : https://www.koha-community.org/<br>git : https://git.koha-community.org/<br>bugs : https://bugs.koha-community.org/<br><br><br>------------------------------<br><br>End of Koha-devel Digest, Vol 201, Issue 9<br>******************************************<br></div><br><br>NOTE: You are receiving this mail because, the Requester/Technician wanted you to get notified on this request creation.<br></body></html>