Favorites: Don't count private photos #334

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-06-04 17:33:00 +02:00
parent 916e3a570c
commit c0a3ab5ac5
2 changed files with 2 additions and 2 deletions

View file

@ -192,7 +192,7 @@ func (c *Config) ClientConfig() ClientConfig {
Take(&result.Count) Take(&result.Count)
c.Db().Table("photos"). c.Db().Table("photos").
Select("SUM(photo_type = 'video' AND photo_quality >= 0 AND photo_private = 0) AS videos, SUM(photo_type IN ('image','raw','live') AND photo_quality < 3 AND photo_quality >= 0 AND photo_private = 0) AS review, SUM(photo_quality = -1) AS hidden, SUM(photo_type IN ('image','raw','live') AND photo_private = 0 AND photo_quality >= 0) AS photos, SUM(photo_favorite = 1 AND photo_quality >= 0) AS favorites, SUM(photo_private = 1 AND photo_quality >= 0) AS private"). Select("SUM(photo_type = 'video' AND photo_quality >= 0 AND photo_private = 0) AS videos, SUM(photo_type IN ('image','raw','live') AND photo_quality < 3 AND photo_quality >= 0 AND photo_private = 0) AS review, SUM(photo_quality = -1) AS hidden, SUM(photo_type IN ('image','raw','live') AND photo_private = 0 AND photo_quality >= 0) AS photos, SUM(photo_favorite = 1 AND photo_private = 0 AND photo_quality >= 0) AS favorites, SUM(photo_private = 1 AND photo_quality >= 0) AS private").
Where("photos.id NOT IN (SELECT photo_id FROM files WHERE file_primary = 1 AND (file_missing = 1 OR file_error <> ''))"). Where("photos.id NOT IN (SELECT photo_id FROM files WHERE file_primary = 1 AND (file_missing = 1 OR file_error <> ''))").
Where("deleted_at IS NULL"). Where("deleted_at IS NULL").
Take(&result.Count) Take(&result.Count)

View file

@ -801,7 +801,7 @@ func (m *Photo) SetFavorite(favorite bool) error {
} }
// Update counters if changed and not deleted. // Update counters if changed and not deleted.
if changed && m.DeletedAt == nil { if changed && m.PhotoPrivate == false && m.DeletedAt == nil {
if favorite { if favorite {
event.Publish("count.favorites", event.Data{ event.Publish("count.favorites", event.Data{
"count": 1, "count": 1,