New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WS categories getImages, TotalCount #777

Closed
erusso87 opened this Issue Sep 19, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@erusso87

erusso87 commented Sep 19, 2017

In order to build a paginator in a client using the API of piwigo, the total count of images is required.

Here:

'count' => count($images)

We are getting the count of the search result, and this information is redundant because a client can count the results in the response. Ex count($result['images'])

Is it possible to include a total_count field, or change the behavior of the actual count?

@modus75 modus75 closed this in 164b595 Sep 30, 2017

plegall added a commit that referenced this issue Sep 30, 2017

@plegall plegall added the Type: Bug label Sep 30, 2017

@plegall plegall added this to the 2.9.2 milestone Sep 30, 2017

@eliz82

This comment has been minimized.

eliz82 commented Oct 7, 2017

I have asked for this more then 1 year and a half ago: http://piwigo.org/forum/viewtopic.php?pid=163539#p163539
Is nobody reading the forum?

Hmm, finally we have total number of unique pictures. I think now we can calculate the correct pagination when getting pictures from a category in recursive mode. I didn't tested yet on galleries that have pictures in multiples categories, but I think this will be fine.

The problem with the modification you made is that you have added this parameter with the same key name like the old one that showed a total different result (the number of images on that request based on "per page" parameter). This was more a lack of a future then a bug. Now what developers will do?

option 1-we must break the compatibility with all version before 2.9.2 ? .... of course this is not possible. We cannot let old versions of piwigo in the air.
option 2-we must get for info about what version is the gallery and use an old method for 2.9.1- and a new one for 2.9.2 (better because will show the total unique pictures).
this will:
-complicate our code
-slow down the response (make a new API request to read the piwigo version using pwg.getInfos ... i think this also need authentication, so unusable for remote sites)

Idea:
Everything was such more easier if you have added this as a new parameter example "total_count". Then it was so simple to keep compatibility between old and new versions of piwigo.

example:

if (!empty($api_response['result']['total_count'] )) { //check if array key exist (for 2.9.2+)
    //use the new method for counting (this is better because we have the total number of unique pictures
}
else { //(for piwigo 2.9.1-)
    //use old method for counting. example https://github.com/eliz82/piwigo2img/blob/master/piwigo2img.php#L262-L273
}
@modus75

This comment has been minimized.

Contributor

modus75 commented Oct 8, 2017

You're right there should be a total count as in the other api calls

@modus75 modus75 reopened this Oct 8, 2017

@eliz82

This comment has been minimized.

eliz82 commented Oct 13, 2017

Well ... just rename'it "total_count" or something like that. In this way we can check if this new api parameter exist and use new or old method for calculation pagination depending of the Piwigo version.

It remain to you if you let the old "count" also, but like user who reported this said, that "parameter" is redundant . You can always count the number of images by yourself using something like
count($api_response['result']['images'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment