blob: 24aaf66d4baeae3ae748fb9030a32b98a5d21b3e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# frozen_string_literal: true
# == Schema Information
#
# Table name: collection_items
#
# id :bigint(8) not null, primary key
# account_id :bigint(8)
# uri :string not null
# processed :boolean default(FALSE), not null
# retries :integer default(0), not null
#
class CollectionItem < ApplicationRecord
belongs_to :account, inverse_of: :collection_items, optional: true
default_scope { order(id: :desc) }
scope :unprocessed, -> { where(processed: false) }
scope :joins_on_collection_pages, -> { joins('LEFT OUTER JOIN collection_pages ON collection_pages.account_id = collection_items.account_id') }
scope :inactive, -> { joins_on_collection_pages.where('collection_pages.account_id IS NULL') }
scope :active, -> { joins_on_collection_pages.where('collection_pages.account_id IS NOT NULL') }
end
|