Commit ccdc7f86 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 2c9d1abf 3da8152e
---
name: disable_joins_upstream_downstream_projects
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71247
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/341791
milestone: '14.4'
type: development
group: group::sharding
default_enabled: false
...@@ -256,10 +256,6 @@ hub_docker_quota_check: ...@@ -256,10 +256,6 @@ hub_docker_quota_check:
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq --raw-output .token) && curl --head --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" 2>&1 TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq --raw-output .token) && curl --head --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" 2>&1
``` ```
## Use the NPM Dependency Proxy for NPM packages
For information on this, see [Dependency Proxy](../npm_registry/#dependency-proxy).
## Troubleshooting ## Troubleshooting
### Dependency Proxy Connection Failure ### Dependency Proxy Connection Failure
......
...@@ -614,8 +614,3 @@ The GitLab npm repository supports the following commands for the npm CLI (`npm` ...@@ -614,8 +614,3 @@ The GitLab npm repository supports the following commands for the npm CLI (`npm`
- `npm view`: Show package metadata. - `npm view`: Show package metadata.
- `yarn add`: Install an npm package. - `yarn add`: Install an npm package.
- `yarn update`: Update your dependencies. - `yarn update`: Update your dependencies.
## Dependency Proxy
The NPM Dependency Proxy for NPM packages isn't available. For more information, see
[this epic](https://gitlab.com/groups/gitlab-org/-/epics/3608).
...@@ -191,7 +191,7 @@ module EE ...@@ -191,7 +191,7 @@ module EE
def project_has_subscriptions? def project_has_subscriptions?
project.feature_available?(:ci_project_subscriptions) && project.feature_available?(:ci_project_subscriptions) &&
project.downstream_projects.any? project.downstream_project_subscriptions.any?
end end
def merge_train_ref? def merge_train_ref?
......
...@@ -93,9 +93,9 @@ module EE ...@@ -93,9 +93,9 @@ module EE
has_many :project_aliases has_many :project_aliases
has_many :upstream_project_subscriptions, class_name: 'Ci::Subscriptions::Project', foreign_key: :downstream_project_id, inverse_of: :downstream_project has_many :upstream_project_subscriptions, class_name: 'Ci::Subscriptions::Project', foreign_key: :downstream_project_id, inverse_of: :downstream_project
has_many :upstream_projects, class_name: 'Project', through: :upstream_project_subscriptions, source: :upstream_project has_many :upstream_projects, class_name: 'Project', through: :upstream_project_subscriptions, source: :upstream_project, disable_joins: -> { ::Feature.enabled?(:disable_joins_upstream_downstream_projects, default_enabled: :yaml) }
has_many :downstream_project_subscriptions, class_name: 'Ci::Subscriptions::Project', foreign_key: :upstream_project_id, inverse_of: :upstream_project has_many :downstream_project_subscriptions, class_name: 'Ci::Subscriptions::Project', foreign_key: :upstream_project_id, inverse_of: :upstream_project
has_many :downstream_projects, class_name: 'Project', through: :downstream_project_subscriptions, source: :downstream_project has_many :downstream_projects, class_name: 'Project', through: :downstream_project_subscriptions, source: :downstream_project, disable_joins: -> { ::Feature.enabled?(:disable_joins_upstream_downstream_projects, default_enabled: :yaml) }
has_many :sourced_pipelines, class_name: 'Ci::Sources::Project', foreign_key: :source_project_id has_many :sourced_pipelines, class_name: 'Ci::Sources::Project', foreign_key: :source_project_id
...@@ -795,6 +795,14 @@ module EE ...@@ -795,6 +795,14 @@ module EE
available_features[feature] available_features[feature]
end end
def upstream_projects_count
upstream_project_subscriptions.count
end
def downstream_projects_count
downstream_project_subscriptions.count
end
def merge_pipelines_enabled? def merge_pipelines_enabled?
return false unless ci_cd_settings return false unless ci_cd_settings
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
%h5 %h5
= _("Subscriptions") = _("Subscriptions")
%span.badge.badge-pill %span.badge.badge-pill
= @project.upstream_projects.count + @project.downstream_projects.count = @project.upstream_projects_count + @project.downstream_projects_count
%table.table.gl-mt-3 %table.table.gl-mt-3
%thead %thead
......
...@@ -3032,6 +3032,54 @@ RSpec.describe Project do ...@@ -3032,6 +3032,54 @@ RSpec.describe Project do
end end
end end
describe '#upstream_projects' do
it 'returns the upstream projects' do
primary_project = create(:project, :public)
upstream_project = create(:project, :public)
primary_project.upstream_projects << upstream_project
with_cross_joins_prevented do
expect(primary_project.upstream_projects).to eq([upstream_project])
end
end
end
describe '#upstream_projects_count' do
it 'returns the upstream projects count' do
primary_project = create(:project, :public)
upstream_projects = create_list(:project, 2, :public)
primary_project.upstream_projects = upstream_projects
with_cross_joins_prevented do
expect(primary_project.upstream_projects_count).to eq(2)
end
end
end
describe '#downstream_projects' do
it 'returns the downstream projects' do
primary_project = create(:project, :public)
downstream_project = create(:project, :public)
primary_project.downstream_projects << downstream_project
with_cross_joins_prevented do
expect(primary_project.downstream_projects).to eq([downstream_project])
end
end
end
describe '#downstream_projects_count' do
it 'returns the downstream projects count' do
primary_project = create(:project, :public)
downstream_projects = create_list(:project, 2, :public)
primary_project.downstream_projects = downstream_projects
with_cross_joins_prevented do
expect(primary_project.downstream_projects_count).to eq(2)
end
end
end
describe '#vulnerability_report_rule' do describe '#vulnerability_report_rule' do
subject { project.vulnerability_report_rule } subject { project.vulnerability_report_rule }
......
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