Skip to content

Commit

Permalink
Add new scope to notices to filter out notices with attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-hank committed Jan 3, 2023
1 parent e5000f4 commit 40a2922
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/notice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class Notice < ApplicationRecord

# == Scopes ===============================================================
scope :top_notices_token_urls, -> { joins(:archived_token_urls).select('notices.*, COUNT(archived_token_urls.id) AS counted_archived_token_urls').group('notices.id') }
scope :with_attachments, -> { includes(:file_uploads).where.not(file_uploads: { id: nil }) }

# == Aliases ==============================================================
alias_attribute :tags, :tag_list
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/rails_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
# avoid calling it.
limited_pagination true

scopes [nil, :with_attachments]

field :id
field :title
field(:date_sent) { label 'Sent' }
Expand Down

0 comments on commit 40a2922

Please sign in to comment.