Rename GeoNode#project_ids to restricted_project_ids

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