Rename GeoNode#project_ids to restricted_project_ids

parent 88a21685
......@@ -108,7 +108,7 @@ class GeoNode < ActiveRecord::Base
end
end
def project_ids
def restricted_project_ids
return unless namespaces.presence
relations = namespaces.map { |namespace| namespace.all_projects.select(:id) }
......@@ -119,34 +119,34 @@ class GeoNode < ActiveRecord::Base
end
def lfs_objects
if project_ids
LfsObject.joins(:projects).where(projects: { id: project_ids })
if restricted_project_ids
LfsObject.joins(:projects).where(projects: { id: restricted_project_ids })
else
LfsObject.all
end
end
def projects
if project_ids
Project.where(id: project_ids)
if restricted_project_ids
Project.where(id: restricted_project_ids)
else
Project.all
end
end
def project_registries
if project_ids
Geo::ProjectRegistry.where(project_id: project_ids)
if restricted_project_ids
Geo::ProjectRegistry.where(project_id: restricted_project_ids)
else
Geo::ProjectRegistry.all
end
end
def uploads
if project_ids
if restricted_project_ids
uploads_table = Upload.arel_table
group_uploads = uploads_table[:model_type].eq('Namespace').and(uploads_table[:model_id].in(Gitlab::Geo.current_node.namespace_ids))
project_uploads = uploads_table[:model_type].eq('Project').and(uploads_table[:model_id].in(project_ids))
project_uploads = uploads_table[:model_type].eq('Project').and(uploads_table[:model_id].in(restricted_project_ids))
other_uploads = uploads_table[:model_type].not_in(%w[Namespace Project])
Upload.where(group_uploads.or(project_uploads).or(other_uploads))
......
......@@ -54,7 +54,7 @@ class GeoNodeStatus
@lfs_objects_synced_count ||= begin
relation = Geo::FileRegistry.where(file_type: :lfs)
if Gitlab::Geo.current_node.project_ids
if Gitlab::Geo.current_node.restricted_project_ids
relation = relation.where(file_id: lfs_objects.pluck(:id))
end
......
......@@ -33,7 +33,7 @@
%span.help-block Primary node
- else
= status_loading_icon
- if node.project_ids
- if node.restricted_project_ids
%p
%span.help-block
Namespaces to replicate:
......
......@@ -11,7 +11,7 @@ module Geo
try_obtain_lease do
geo_node = GeoNode.find(geo_node_id)
restricted_project_ids = geo_node.project_ids
restricted_project_ids = geo_node.restricted_project_ids
return unless restricted_project_ids
Project.where.not(id: restricted_project_ids).find_in_batches(batch_size: BATCH_SIZE) do |batch|
......
......@@ -98,9 +98,9 @@ module Gitlab
def can_replay?(event_log)
return true if event_log.project_id.nil?
return true if Gitlab::Geo.current_node.project_ids.nil?
return true if Gitlab::Geo.current_node.restricted_project_ids.nil?
Gitlab::Geo.current_node.project_ids.include?(event_log.project_id)
Gitlab::Geo.current_node.restricted_project_ids.include?(event_log.project_id)
end
def handle_repository_update(updated_event)
......
......@@ -317,10 +317,10 @@ describe GeoNode, type: :model do
end
end
describe '#project_ids' do
describe '#restricted_project_ids' do
context 'without namespace restriction' do
it 'returns nil' do
expect(node.project_ids).to be_nil
expect(node.restricted_project_ids).to be_nil
end
end
......@@ -335,7 +335,7 @@ describe GeoNode, type: :model do
node.update_attribute(:namespaces, [group_1, group_2, nested_group_1])
expect(node.project_ids).to match_array([project_1.id, project_2.id, project_3.id])
expect(node.restricted_project_ids).to match_array([project_1.id, project_2.id, project_3.id])
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