Commit de9c17c2 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Mike Kozono

Remove FDW LFS objects models

FDW queries to replicate LFS objects has been removed. These
models are not necessary anymore.
parent cf7be1a2
# frozen_string_literal: true
module Geo
module Fdw
class LfsObject < ::Geo::BaseFdw
include ObjectStorable
STORE_COLUMN = :file_store
self.primary_key = :id
self.table_name = Gitlab::Geo::Fdw.foreign_table_name('lfs_objects')
has_many :lfs_objects_projects, class_name: 'Geo::Fdw::LfsObjectsProject'
has_many :projects, class_name: 'Geo::Fdw::Project', through: :lfs_objects_projects
scope :project_id_in, ->(ids) { joins(:projects).merge(Geo::Fdw::Project.id_in(ids)) }
class << self
def failed
inner_join_registry
.merge(Geo::LfsObjectRegistry.failed)
end
def inner_join_registry
join_statement =
arel_table
.join(registry_table, Arel::Nodes::InnerJoin)
.on(arel_table[:id].eq(registry_table[:lfs_object_id]))
joins(join_statement.join_sources)
end
def missing_registry
left_outer_join_registry
.where(registry_table[:id].eq(nil))
end
def missing_on_primary
inner_join_registry
.merge(Geo::LfsObjectRegistry.synced.missing_on_primary)
end
def synced
inner_join_registry
.merge(Geo::LfsObjectRegistry.synced)
end
private
def registry_table
Geo::LfsObjectRegistry.arel_table
end
def left_outer_join_registry
join_statement =
arel_table
.join(registry_table, Arel::Nodes::OuterJoin)
.on(arel_table[:id].eq(registry_table[:lfs_object_id]))
joins(join_statement.join_sources)
end
end
end
end
end
# frozen_string_literal: true
module Geo
module Fdw
class LfsObjectsProject < ::Geo::BaseFdw
self.table_name = Gitlab::Geo::Fdw.foreign_table_name('lfs_objects_projects')
belongs_to :lfs_object, class_name: 'Geo::Fdw::LfsObject', inverse_of: :projects
belongs_to :project, class_name: 'Geo::Fdw::Project', inverse_of: :lfs_objects
scope :project_id_in, ->(ids) { where(project_id: ids) }
end
end
end
...@@ -10,8 +10,6 @@ module Geo ...@@ -10,8 +10,6 @@ module Geo
self.table_name = Gitlab::Geo::Fdw.foreign_table_name('projects') self.table_name = Gitlab::Geo::Fdw.foreign_table_name('projects')
has_many :job_artifacts, class_name: 'Geo::Fdw::Ci::JobArtifact' has_many :job_artifacts, class_name: 'Geo::Fdw::Ci::JobArtifact'
has_many :lfs_objects_projects, class_name: 'Geo::Fdw::LfsObjectsProject'
has_many :lfs_objects, class_name: 'Geo::Fdw::LfsObject', through: :lfs_objects_projects
has_many :container_repositories, class_name: 'Geo::Fdw::ContainerRepository' has_many :container_repositories, class_name: 'Geo::Fdw::ContainerRepository'
belongs_to :namespace, class_name: 'Geo::Fdw::Namespace' belongs_to :namespace, class_name: 'Geo::Fdw::Namespace'
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::Fdw::LfsObject, :geo, type: :model do
context 'relationships' do
it { is_expected.to have_many(:lfs_objects_projects).class_name('Geo::Fdw::LfsObjectsProject') }
it { is_expected.to have_many(:projects).class_name('Geo::Fdw::Project').through(:lfs_objects_projects) }
end
describe '.missing_registry', :geo_fdw do
it "returns lfs objects that don't have a corresponding registry entry" do
missing_registry_entries = create_list(:lfs_object, 2)
create_list(:lfs_object, 2).each do |lfs|
create(:geo_lfs_object_registry, lfs_object_id: lfs.id)
end
expect(described_class.missing_registry).to match_ids(missing_registry_entries)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Geo::Fdw::LfsObjectsProject, :geo, type: :model do
context 'relationships' do
it { is_expected.to belong_to(:lfs_object).class_name('Geo::Fdw::LfsObject').inverse_of(:projects) }
it { is_expected.to belong_to(:project).class_name('Geo::Fdw::Project').inverse_of(:lfs_objects) }
end
end
...@@ -5,8 +5,6 @@ require 'spec_helper' ...@@ -5,8 +5,6 @@ require 'spec_helper'
RSpec.describe Geo::Fdw::Project, :geo_fdw, type: :model do RSpec.describe Geo::Fdw::Project, :geo_fdw, type: :model do
context 'relationships' do context 'relationships' do
it { is_expected.to have_many(:job_artifacts).class_name('Geo::Fdw::Ci::JobArtifact') } it { is_expected.to have_many(:job_artifacts).class_name('Geo::Fdw::Ci::JobArtifact') }
it { is_expected.to have_many(:lfs_objects_projects).class_name('Geo::Fdw::LfsObjectsProject') }
it { is_expected.to have_many(:lfs_objects).class_name('Geo::Fdw::LfsObject').through(:lfs_objects_projects) }
it { is_expected.to have_many(:container_repositories).class_name('Geo::Fdw::ContainerRepository') } it { is_expected.to have_many(:container_repositories).class_name('Geo::Fdw::ContainerRepository') }
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