diff --git a/app/models/card.rb b/app/models/card.rb index 24c7aa079..9175d6b96 100644 --- a/app/models/card.rb +++ b/app/models/card.rb @@ -1,11 +1,10 @@ class Card < ApplicationRecord include Assignable, Attachments, Cacheable, Closeable, Colored, Entropic, Eventable, Golden, Mentions, Multistep, Pinnable, Postponable, Promptable, Readable, Searchable, - Staged, Stallable, Statuses, Taggable, Watchable + Staged, Stallable, Statuses, Taggable, Triageable, Watchable belongs_to :collection, touch: true belongs_to :creator, class_name: "User", default: -> { Current.user } - belongs_to :column, optional: true has_many :comments, dependent: :destroy has_one_attached :image, dependent: :purge_later diff --git a/app/models/card/triageable.rb b/app/models/card/triageable.rb new file mode 100644 index 000000000..5a297b7c9 --- /dev/null +++ b/app/models/card/triageable.rb @@ -0,0 +1,10 @@ +module Card::Triageable + extend ActiveSupport::Concern + + included do + belongs_to :column, optional: true + + scope :untriaged, -> { where.missing(:column) } + scope :triaged, -> { joins(:column) } + end +end diff --git a/app/models/collection.rb b/app/models/collection.rb index 6f50d2d4a..bd4d403c7 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -1,11 +1,10 @@ class Collection < ApplicationRecord - include AutoClosing, Accessible, Broadcastable, Entropic, Filterable, Publishable, Workflowing + include AutoClosing, Accessible, Broadcastable, Entropic, Filterable, Publishable, Triageable, Workflowing belongs_to :creator, class_name: "User", default: -> { Current.user } has_rich_text :public_description - has_many :columns, dependent: :destroy has_many :cards, dependent: :destroy has_many :tags, -> { distinct }, through: :cards has_many :events diff --git a/app/models/collection/triageable.rb b/app/models/collection/triageable.rb new file mode 100644 index 000000000..a314868c8 --- /dev/null +++ b/app/models/collection/triageable.rb @@ -0,0 +1,7 @@ +module Collection::Triageable + extend ActiveSupport::Concern + + included do + has_many :columns, dependent: :destroy + end +end