After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 759331 - Don't show empty albums in favorites
Don't show empty albums in favorites
Status: RESOLVED FIXED
Product: gnome-photos
Classification: Applications
Component: general
3.19.x
Other All
: Normal normal
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-12-11 08:40 UTC by Debarshi Ray
Modified: 2015-12-15 13:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
search-type-manager: Skip empty collections in Favorites (1.32 KB, patch)
2015-12-11 08:49 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2015-12-11 08:40:36 UTC
If someone had created an album with some pictures in it, then marked it as favorite, and afterwards removed all the items from it, the album will still show up in Favorites. It shouldn't.

This is because our inner SELECT looks like this:
SELECT ?urn rdf:type (?urn) AS ?type COUNT (?item) AS ?count
WHERE {
  ?urn nao:hasTag nao:predefined-tag-favorite
}
GROUP BY (?urn)

Since ?item is undefined, COUNT(?item) comes out as COUNT(?urn), which is going to be greater than zero since the empty album has nao:predefined-tag-favorite attached to it.

This beats the FILTER(?count > 0) in the outer SELECT and shows the empty album.

Instead, our inner SELECT should be:
SELECT ?urn rdf:type (?urn) AS ?type COUNT (?item) AS ?count
WHERE {
  ?urn a rdfs:Resource; nao:hasTag nao:predefined-tag-favorite.
  OPTIONAL {?item a nie:InformationElement; nie:isPartOf ?urn}
}
GROUP BY (?urn)
Comment 1 Debarshi Ray 2015-12-11 08:47:11 UTC
This should complete the fix for bug 725589
Comment 2 Debarshi Ray 2015-12-11 08:49:05 UTC
Created attachment 317187 [details] [review]
search-type-manager: Skip empty collections in Favorites
Comment 3 Debarshi Ray 2015-12-11 16:19:21 UTC
(In reply to Debarshi Ray from comment #0)
> This is because our inner SELECT looks like this:
> SELECT ?urn rdf:type (?urn) AS ?type COUNT (?item) AS ?count
> WHERE {
>   ?urn nao:hasTag nao:predefined-tag-favorite
> }
> GROUP BY (?urn)

The fact that tracker doesn't complain about the unbound ?foo is a bug. See bug 759361
Comment 4 Debarshi Ray 2015-12-15 13:55:14 UTC
Been using it for some days and I haven't seen any breakage. Pushed to master.