Search returns total different than actual number of snaps

Bug #1888664 reported by Toto Bille
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snap Store Server
Confirmed
Low
Unassigned

Bug Description

Reported here: https://github.com/canonical-web-and-design/snapcraft.io/issues/2971

It seems that when searching for zsh the result gives 3 snaps but the total calculated of snaps is 4.

To reproduce:

```
curl -H 'X-Ubuntu-Store: ubuntu' "https://api.snapcraft.io/api/v1/snaps/search?q=zsh" | jq`
{
  "total": 4,
  "_embedded": {
    "clickindex:package": [{...},{...},{...}]
  },
  ...
}
```

Daniel Manrique (roadmr)
Changed in snapstore-server:
status: New → Confirmed
Revision history for this message
Daniel Manrique (roadmr) wrote :

There's a "ghost snap" in the results for zsh, namely 'zsh-shell', this is a snap that had releases at some point but now has all its channels closed.

The list of 3 snaps is therefore accurate, those are the three that do have published releases. There might be a quirk in the logic to calculate the "total" value, because that is done on the list of snaps whose information did match the search criteria. So:

1- search for snaps matching "zsh" in the snap index, this returns 4 results.
2- When building the list of details for snaps, actually look at which ones have released revisions, and only 3 of the originally-found 4 do.
3- Calculate "total" based on the 4 results from #1, not the 3 from the properly-filtered list fom #2.

This probably needs fixing store-side, but note also that the "search" api is deprecated and you should be using the newer "find" api instead (http://api.snapcraft.io/docs/search.html#snaps_find).

Changed in snapstore-server:
importance: Undecided → Low
Revision history for this message
William Grant (wgrant) wrote :

It's normal for searches to return approximate numbers. Consider, for example, what happens if a snaps leaves or enters the result set during navigation. I don't consider this to be a bug.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.