[Koha-devel] Getting "count" when using REST API

dcook at prosentient.com.au dcook at prosentient.com.au
Fri Aug 5 02:31:42 CEST 2022


How do you mean?

 

In my case, I’m improving how my Keycloak User Storage extension works with Koha. It fetches the count of users and then sends an API request using an offset and that count to handle the paging. Their internal API breaks it into 2 steps, so I have to hit the database twice anyway. 

 

David Cook

Senior Software Engineer

Prosentient Systems

Suite 7.03

6a Glen St

Milsons Point NSW 2061

Australia

 

Office: 02 9212 0899

Online: 02 8005 0595

 

From: Tomas Cohen Arazi <tomascohen at gmail.com> 
Sent: Friday, 5 August 2022 10:26 AM
To: David Cook <dcook at prosentient.com.au>
Cc: Jonathan Druart <jonathan.druart at gmail.com>; Koha Devel <koha-devel at lists.koha-community.org>
Subject: Re: [Koha-devel] Getting "count" when using REST API

 

That's a smart trick!

 

We should not be lazy though, and add a generic way to retrieve the count without making several DB hits.

 

El jue, 4 ago 2022 20:56, <dcook at prosentient.com.au <mailto:dcook at prosentient.com.au> > escribió:

Jonathan, you are a champion! That'll work perfectly for me! 

David Cook
Senior Software Engineer
Prosentient Systems
Suite 7.03
6a Glen St
Milsons Point NSW 2061
Australia

Office: 02 9212 0899
Online: 02 8005 0595

-----Original Message-----
From: Jonathan Druart <jonathan.druart at gmail.com <mailto:jonathan.druart at gmail.com> > 
Sent: Thursday, 4 August 2022 10:17 PM
To: Tomas Cohen Arazi <tomascohen at gmail.com <mailto:tomascohen at gmail.com> >
Cc: David Cook <dcook at prosentient.com.au <mailto:dcook at prosentient.com.au> >; Koha Devel <koha-devel at lists.koha-community.org <mailto:koha-devel at lists.koha-community.org> >
Subject: Re: [Koha-devel] Getting "count" when using REST API

 I needed that for ERM and I did a GET with _page=1 and _per_page=1 (to retrieve only 1 result) then read the X-Total-Count value from the header's response ;)

Le jeu. 4 août 2022 à 12:33, Tomas Cohen Arazi <tomascohen at gmail.com <mailto:tomascohen at gmail.com> > a écrit :
>
> Only with x-koha-embed
>
>
> El jue, 4 ago 2022 3:54, <dcook at prosentient.com.au <mailto:dcook at prosentient.com.au> > escribió:
>>
>> Hi all,
>>
>>
>>
>> Is there a method for getting a “count” using the REST API without fetching every record?
>>
>>
>>
>> When building a paging lookup outside of Koha, it would be useful to get a total record count and then just fetch the page of records that you need.
>>
>>
>>
>> Thanks!
>>
>>
>>
>> David Cook
>>
>> Senior Software Engineer
>>
>> Prosentient Systems
>>
>> Suite 7.03
>>
>> 6a Glen St
>>
>> Milsons Point NSW 2061
>>
>> Australia
>>
>>
>>
>> Office: 02 9212 0899
>>
>> Online: 02 8005 0595
>>
>>
>
> _______________________________________________
> Koha-devel mailing list
> Koha-devel at lists.koha-community.org <mailto:Koha-devel at lists.koha-community.org> 
> https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : https://www.koha-community.org/ git : 
> https://git.koha-community.org/ bugs : 
> https://bugs.koha-community.org/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20220805/ec8edf4e/attachment.htm>


More information about the Koha-devel mailing list