Skip to content

Improve Album suggestions SOG page #565

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

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/models/photo_album.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@
scope :publicly_visible, -> { where(publicly_visible: true) }

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

Check warning on line 15 in app/models/photo_album.rb

View check run for this annotation

Codecov / codecov/patch

app/models/photo_album.rb#L15

Added line #L15 was not covered by tests
.joins(:photos)
.left_joins(photos: :tags)
.group('photo_albums.id')
.having(<<~SQL.squish)
(
COALESCE(COUNT(DISTINCT photo_tags.photo_id), 0) * 1.0 / COUNT(DISTINCT photos.id)
) < 0.85
SQL
.select('photo_albums.id')
where(id: qualifying_album_ids_subquery)

Check warning on line 25 in app/models/photo_album.rb

View check run for this annotation

Codecov / codecov/patch

app/models/photo_album.rb#L25

Added line #L25 was not covered by tests
}

def owners
Expand Down
Loading