Commit 75638b38 authored by Michael Kozono's avatar Michael Kozono

Dry up scopes

parent e26af09f
module ObjectStorable
extend ActiveSupport::Concern
included do
scope :with_files_stored_locally, -> { where(self::STORE_COLUMN => [nil, ObjectStorage::Store::LOCAL]) }
scope :with_files_stored_remotely, -> { where(self::STORE_COLUMN => ObjectStorage::Store::REMOTE) }
end
end
...@@ -2,10 +2,12 @@ module Geo ...@@ -2,10 +2,12 @@ module Geo
module Fdw module Fdw
module Ci module Ci
class JobArtifact < ::Geo::BaseFdw class JobArtifact < ::Geo::BaseFdw
include ObjectStorable
STORE_COLUMN = :file_store
self.table_name = Gitlab::Geo::Fdw.table('ci_job_artifacts') self.table_name = Gitlab::Geo::Fdw.table('ci_job_artifacts')
scope :with_files_stored_locally, -> { where(file_store: [nil, JobArtifactUploader::Store::LOCAL]) }
scope :with_files_stored_remotely, -> { where(file_store: JobArtifactUploader::Store::REMOTE) }
scope :not_expired, -> { where('expire_at IS NULL OR expire_at > ?', Time.current) } scope :not_expired, -> { where('expire_at IS NULL OR expire_at > ?', Time.current) }
scope :geo_syncable, -> { with_files_stored_locally.not_expired } scope :geo_syncable, -> { with_files_stored_locally.not_expired }
end end
......
module Geo module Geo
module Fdw module Fdw
class LfsObject < ::Geo::BaseFdw class LfsObject < ::Geo::BaseFdw
include ObjectStorable
STORE_COLUMN = :file_store
self.table_name = Gitlab::Geo::Fdw.table('lfs_objects') self.table_name = Gitlab::Geo::Fdw.table('lfs_objects')
scope :with_files_stored_locally, -> { where(file_store: [nil, LfsObjectUploader::Store::LOCAL]) }
scope :with_files_stored_remotely, -> { where(file_store: LfsObjectUploader::Store::REMOTE) }
scope :geo_syncable, -> { with_files_stored_locally } scope :geo_syncable, -> { with_files_stored_locally }
end end
end end
......
module Geo module Geo
module Fdw module Fdw
class Upload < ::Geo::BaseFdw class Upload < ::Geo::BaseFdw
include ObjectStorable
STORE_COLUMN = :store
self.table_name = Gitlab::Geo::Fdw.table('uploads') self.table_name = Gitlab::Geo::Fdw.table('uploads')
scope :with_files_stored_locally, -> { where(store: [nil, ObjectStorage::Store::LOCAL]) }
scope :with_files_stored_remotely, -> { where(store: ObjectStorage::Store::REMOTE) }
scope :geo_syncable, -> { with_files_stored_locally } scope :geo_syncable, -> { with_files_stored_locally }
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment