Skip to content

Commit

Permalink
Add filter for albums without photos that have tags (#432)
Browse files Browse the repository at this point in the history
* Add filter for albums without photos that have tags

* Lint
  • Loading branch information
wilco375 authored Oct 11, 2024
1 parent 3da6176 commit 45b78a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/photo_album.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class PhotoAlbum < ApplicationRecord

scope :publicly_visible, (-> { where(publicly_visible: true) })

scope :without_photo_tags, lambda {
where.not(id: Photo.joins(:tags).select(:photo_album_id).distinct)
}

def owners
if group.present?
group.active_users + [author]
Expand Down
2 changes: 2 additions & 0 deletions app/resources/v1/photo_album_resource.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class V1::PhotoAlbumResource < V1::ApplicationResource
attributes :title, :date, :publicly_visible

filter :without_photo_tags, apply: ->(records, _value, _options) { records.without_photo_tags }

has_many :photos
has_one :author, always_include_linkage_data: true
has_one :group, always_include_linkage_data: true
Expand Down

0 comments on commit 45b78a7

Please sign in to comment.