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
484d9c56
Commit
484d9c56
authored
Oct 22, 2021
by
Paul Gascou-Vaillancourt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify pipelines count query
parent
28ab2325
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
21 deletions
+4
-21
ee/app/helpers/projects/on_demand_scans_helper.rb
ee/app/helpers/projects/on_demand_scans_helper.rb
+3
-18
ee/spec/helpers/projects/on_demand_scans_helper_spec.rb
ee/spec/helpers/projects/on_demand_scans_helper_spec.rb
+1
-3
No files found.
ee/app/helpers/projects/on_demand_scans_helper.rb
View file @
484d9c56
# frozen_string_literal: true
# frozen_string_literal: true
module
Projects::OnDemandScansHelper
module
Projects::OnDemandScansHelper
include
API
::
Helpers
::
GraphqlHelpers
# rubocop: disable CodeReuse/ActiveRecord
def
on_demand_scans_data
(
project
)
def
on_demand_scans_data
(
project
)
query
=
%(
{
project(fullPath: "#{project.full_path}") {
pipelines(source: "dast") {
count
}
}
}
)
pipelines_count
=
run_graphql!
(
query:
query
,
context:
{
current_user:
current_user
},
transform:
->
(
result
)
{
result
.
dig
(
'data'
,
'project'
,
'pipelines'
,
'count'
)
}
)
common_data
(
project
).
merge
({
common_data
(
project
).
merge
({
'pipelines-count'
=>
p
ipelines_
count
,
'pipelines-count'
=>
p
roject
.
all_pipelines
.
where
(
source:
Enums
::
Ci
::
Pipeline
.
sources
[
:ondemand_dast_scan
]).
count
,
'new-dast-scan-path'
=>
new_project_on_demand_scan_path
(
project
),
'new-dast-scan-path'
=>
new_project_on_demand_scan_path
(
project
),
'empty-state-svg-path'
=>
image_path
(
'illustrations/empty-state/ondemand-scan-empty.svg'
)
'empty-state-svg-path'
=>
image_path
(
'illustrations/empty-state/ondemand-scan-empty.svg'
)
})
})
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
on_demand_scans_form_data
(
project
)
def
on_demand_scans_form_data
(
project
)
common_data
(
project
).
merge
({
common_data
(
project
).
merge
({
...
...
ee/spec/helpers/projects/on_demand_scans_helper_spec.rb
View file @
484d9c56
...
@@ -3,8 +3,6 @@
...
@@ -3,8 +3,6 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Projects
::
OnDemandScansHelper
do
RSpec
.
describe
Projects
::
OnDemandScansHelper
do
include
Devise
::
Test
::
ControllerHelpers
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
before
do
before
do
...
@@ -13,7 +11,7 @@ RSpec.describe Projects::OnDemandScansHelper do
...
@@ -13,7 +11,7 @@ RSpec.describe Projects::OnDemandScansHelper do
describe
'#on_demand_scans_data'
do
describe
'#on_demand_scans_data'
do
before
do
before
do
allow
(
helper
).
to
receive
(
:run_graphql!
).
and_return
(
12
)
create_list
(
:ci_pipeline
,
12
,
project:
project
,
ref:
'master'
,
source: :ondemand_dast_scan
)
end
end
it
'returns proper data'
do
it
'returns proper data'
do
...
...
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