Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2295c37f
Commit
2295c37f
authored
Sep 28, 2021
by
Adam Hegyi
Committed by
Igor Drozdov
Sep 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cross-join fix for devops adoption
parent
6c3826c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
ee/lib/analytics/devops_adoption/snapshot_calculator.rb
ee/lib/analytics/devops_adoption/snapshot_calculator.rb
+11
-3
spec/support/database/cross-join-allowlist.yml
spec/support/database/cross-join-allowlist.yml
+0
-1
No files found.
ee/lib/analytics/devops_adoption/snapshot_calculator.rb
View file @
2295c37f
...
@@ -61,8 +61,10 @@ module Analytics
...
@@ -61,8 +61,10 @@ module Analytics
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def
runner_configured
def
runner_configured
::
Gitlab
::
Database
.
allow_cross_joins_across_databases
(
url:
'https://gitlab.com/gitlab-org/gitlab/-/issues/337541'
)
do
Ci
::
Runner
.
active
.
belonging_to_group_or_project
(
snapshot_groups
,
snapshot_project_ids
).
exists?
Ci
::
Runner
.
active
.
belonging_to_group_or_project
(
snapshot_groups
,
snapshot_project_ids
).
exists?
end
end
end
def
pipeline_succeeded
def
pipeline_succeeded
Ci
::
Pipeline
.
success
.
for_project
(
snapshot_project_ids
).
updated_before
(
range_end
).
updated_after
(
range_start
).
exists?
Ci
::
Pipeline
.
success
.
for_project
(
snapshot_project_ids
).
updated_before
(
range_end
).
updated_after
(
range_start
).
exists?
...
@@ -119,10 +121,16 @@ module Analytics
...
@@ -119,10 +121,16 @@ module Analytics
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
projects_count_with_artifact
(
artifacts_scope
)
def
projects_count_with_artifact
(
artifacts_scope
)
subquery
=
artifacts_scope
.
created_in_time_range
(
from:
range_start
,
to:
range_end
)
subquery
=
artifacts_scope
.
created_in_time_range
(
from:
range_start
,
to:
range_end
)
.
where
(
Ci
::
JobArtifact
.
arel_table
[
:project_id
].
eq
(
Project
.
arel_table
[
:id
]
)).
arel
.
exists
.
where
(
Ci
::
JobArtifact
.
arel_table
[
:project_id
].
eq
(
Arel
.
sql
(
'project_ids.id'
)
)).
arel
.
exists
snapshot_project_ids
.
each_slice
(
1000
).
sum
do
|
project_ids
|
snapshot_project_ids
.
each_slice
(
1000
).
sum
do
|
project_ids
|
Project
.
where
(
id:
project_ids
).
where
(
subquery
).
count
ids
=
project_ids
.
map
{
|
id
|
[
id
]
}
# To avoid cross-database join, we swap out the FROM part with just the project_ids we need
Project
.
select
(
:id
)
.
from
(
"(
#{
Arel
::
Nodes
::
ValuesList
.
new
(
ids
).
to_sql
}
) project_ids (id)"
)
.
where
(
subquery
)
.
count
end
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
...
...
spec/support/database/cross-join-allowlist.yml
View file @
2295c37f
...
@@ -12,7 +12,6 @@
...
@@ -12,7 +12,6 @@
-
"
./ee/spec/finders/ee/namespaces/projects_finder_spec.rb"
-
"
./ee/spec/finders/ee/namespaces/projects_finder_spec.rb"
-
"
./ee/spec/finders/security/findings_finder_spec.rb"
-
"
./ee/spec/finders/security/findings_finder_spec.rb"
-
"
./ee/spec/graphql/ee/resolvers/namespace_projects_resolver_spec.rb"
-
"
./ee/spec/graphql/ee/resolvers/namespace_projects_resolver_spec.rb"
-
"
./ee/spec/lib/analytics/devops_adoption/snapshot_calculator_spec.rb"
-
"
./ee/spec/lib/ee/gitlab/background_migration/migrate_approver_to_approval_rules_spec.rb"
-
"
./ee/spec/lib/ee/gitlab/background_migration/migrate_approver_to_approval_rules_spec.rb"
-
"
./ee/spec/lib/ee/gitlab/background_migration/migrate_security_scans_spec.rb"
-
"
./ee/spec/lib/ee/gitlab/background_migration/migrate_security_scans_spec.rb"
-
"
./ee/spec/lib/ee/gitlab/background_migration/populate_latest_pipeline_ids_spec.rb"
-
"
./ee/spec/lib/ee/gitlab/background_migration/populate_latest_pipeline_ids_spec.rb"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment