← Back to team overview

dhis2-devs-core team mailing list archive

Re: Paging total being wrong on empty result?

 

This should be fixed now

On Fri Jan 16 2015 at 7:56:45 PM Bob Jolliffe <bobjolliffe@xxxxxxxxx> wrote:

> I agree with you too Mark.  The total should be zero.  Morten does this
> "total" equate to the pageSize in that page count calculation loop?  In
> which case we shouldn't set it to 1, but just not enter the loop at all.
>
> On 16 January 2015 at 12:53, Mark Polak <markpo@xxxxxxxxxx> wrote:
>
>> I agree with you Bob except that the “total” represents the number of
>> results in the resultset. Which is 0 in this case and therefore that is
>> incorrect. The page and pageCount are different depending on how you define
>> a “page”. But i agree with your view on that matter.
>>
>> Kind regards,
>>
>> Mark Polak
>> mark@xxxxxxxxxxxxxxx
>> markpo@xxxxxxxxxx
>> +47 970 36 752
>>
>> On 16 Jan 2015, at 13:51, Bob Jolliffe <bobjolliffe@xxxxxxxxx> wrote:
>>
>> Not really (I don't think).  That commit was related to pageSize to
>> prevent the while loop immediately below entering into an infinite cycle.
>>
>> The current behaviour of the pager in the xample you give seems
>> semantically correct to me.  The pager has returned a page.  And only 1
>> amongst 1.  There is nothing on that page, but that is a different question.
>>
>> On 16 January 2015 at 12:46, Halvdan Grelland <halvdanhg@xxxxxxxxx>
>> wrote:
>>
>>> This
>>> <http://bazaar.launchpad.net/~dhis2-devs-core/dhis2/trunk/revision/17914>
>>> commit from a week ago seems to confirm that this is new behaviour.
>>>
>>> 2015-01-16 13:39 GMT+01:00 Mark Polak <markpo@xxxxxxxxxx>:
>>>
>>>> Hey Morten,
>>>>
>>>> That kind of depends on how you look at the pages. I guess if there
>>>> were 0 results it could still mean 1 page but just with 0 results. Since
>>>> “page” 0 will never exist.
>>>> However if you base the pages of the number of results then i guess it
>>>> should be page 0 and pageCount 0.
>>>>
>>>> That sounds more like a design decision than something that is wrong
>>>> however personally i guess i would like page 1/pageCount 1 more than page
>>>> 0/pageCount 0.
>>>>
>>>> Non the less i agree the total amount should be 0. As now a total of 1
>>>> could mean 1 item or 0 items. Which you can only know based on the data
>>>> returned.
>>>>
>>>> Kind regards,
>>>>
>>>> Mark Polak
>>>> mark@xxxxxxxxxxxxxxx
>>>> markpo@xxxxxxxxxx
>>>> +47 970 36 752
>>>>
>>>> On 16 Jan 2015, at 05:31, Morten Olav Hansen <mortenoh@xxxxxxxxx>
>>>> wrote:
>>>>
>>>> Hi Mark
>>>>
>>>> I think it has been like this since the first time we introduced the
>>>> pager element.. I agree its a bit weird
>>>>
>>>> Total should be 0 of course, do we still want to see pageCount = 1 ?
>>>> even if there is no results? or would that be pagecount = 0 ?
>>>>
>>>> On Thu Jan 15 2015 at 10:44:43 PM Mark Polak <markpo@xxxxxxxxxx> wrote:
>>>>
>>>>> Hey Morten,
>>>>>
>>>>> I ran into a sort of peculiar thing and i believe it is a small bug.
>>>>>
>>>>> When requesting an endpoint with a filter that returns no results. The
>>>>> pager object still marks the total items as being 1.
>>>>>
>>>>> https://apps.dhis2.org/dev/api/dataElements?filter=name:like:sdfdsfsfgdfdd
>>>>>
>>>>> {
>>>>> -pager: {
>>>>> page: 1,
>>>>> pageCount: 1,
>>>>> total: 1
>>>>> },
>>>>> -dataElements: (0)[
>>>>> ]
>>>>> }
>>>>>
>>>>> Kind regards,
>>>>>
>>>>> Mark Polak
>>>>> mark@xxxxxxxxxxxxxxx
>>>>> markpo@xxxxxxxxxx
>>>>> +47 970 36 752
>>>>>
>>>>>
>>>>
>>>> --
>>>> Mailing list: https://launchpad.net/~dhis2-devs-core
>>>> Post to     : dhis2-devs-core@xxxxxxxxxxxxxxxxxxx
>>>> Unsubscribe : https://launchpad.net/~dhis2-devs-core
>>>> More help   : https://help.launchpad.net/ListHelp
>>>>
>>>>
>>>
>>> --
>>> Mailing list: https://launchpad.net/~dhis2-devs-core
>>> Post to     : dhis2-devs-core@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-devs-core
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>>
> --
> Mailing list: https://launchpad.net/~dhis2-devs-core
> Post to     : dhis2-devs-core@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs-core
> More help   : https://help.launchpad.net/ListHelp
>

References