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
228a4f7e
Commit
228a4f7e
authored
Nov 16, 2020
by
Maxime Orefice
Committed by
Sean McGivern
Nov 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Round average coverage to 2 decimal places
parent
0e8c176d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
ee/app/models/ee/ci/daily_build_group_report_result.rb
ee/app/models/ee/ci/daily_build_group_report_result.rb
+2
-2
ee/spec/models/ci/daily_build_group_report_result_spec.rb
ee/spec/models/ci/daily_build_group_report_result_spec.rb
+21
-1
No files found.
ee/app/models/ee/ci/daily_build_group_report_result.rb
View file @
228a4f7e
...
@@ -23,7 +23,7 @@ module EE
...
@@ -23,7 +23,7 @@ module EE
def
self
.
summaries_per_project
def
self
.
summaries_per_project
group
(
:project_id
,
'latest_by_project.date'
).
pluck
(
group
(
:project_id
,
'latest_by_project.date'
).
pluck
(
:project_id
,
:project_id
,
Arel
.
sql
(
"
AVG(cast(data ->> 'coverage' AS FLOAT))
"
),
Arel
.
sql
(
"
ROUND(AVG(CAST(data ->> 'coverage' AS DECIMAL)), 2)::FLOAT
"
),
Arel
.
sql
(
"COUNT(*)"
),
Arel
.
sql
(
"COUNT(*)"
),
Arel
.
sql
(
"latest_by_project.date"
)
Arel
.
sql
(
"latest_by_project.date"
)
).
each_with_object
({})
do
|
(
project_id
,
average_coverage
,
coverage_count
,
date
),
result
|
).
each_with_object
({})
do
|
(
project_id
,
average_coverage
,
coverage_count
,
date
),
result
|
...
@@ -37,7 +37,7 @@ module EE
...
@@ -37,7 +37,7 @@ module EE
def
self
.
activity_per_group
def
self
.
activity_per_group
group
(
:date
).
pluck
(
group
(
:date
).
pluck
(
Arel
.
sql
(
"
AVG(cast(data ->> 'coverage' AS FLOAT))
"
),
Arel
.
sql
(
"
ROUND(AVG(CAST(data ->> 'coverage' AS DECIMAL)), 2)::FLOAT
"
),
Arel
.
sql
(
"COUNT(*)"
),
Arel
.
sql
(
"COUNT(*)"
),
Arel
.
sql
(
"COUNT(DISTINCT ci_daily_build_group_report_results.project_id)"
),
Arel
.
sql
(
"COUNT(DISTINCT ci_daily_build_group_report_results.project_id)"
),
Arel
.
sql
(
"date"
)
Arel
.
sql
(
"date"
)
...
...
ee/spec/models/ci/daily_build_group_report_result_spec.rb
View file @
228a4f7e
...
@@ -48,6 +48,16 @@ RSpec.describe Ci::DailyBuildGroupReportResult do
...
@@ -48,6 +48,16 @@ RSpec.describe Ci::DailyBuildGroupReportResult do
expect
(
summary
).
to
eq
(
expected_summary
)
expect
(
summary
).
to
eq
(
expected_summary
)
end
end
context
'when coverage has more than 3 decimals'
do
let!
(
:build_group_report_result_3
)
do
create
(
:ci_daily_build_group_report_result
,
project:
project_2
,
group_name:
'karma'
,
coverage:
55.55555
)
end
it
'returns average_coverage with 2 decimals'
do
expect
(
summary
[
project_2
.
id
][
:average_coverage
]).
to
eq
(
66.78
)
end
end
it
'executes only 1 SQL query'
do
it
'executes only 1 SQL query'
do
query_count
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}.
count
query_count
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}.
count
...
@@ -101,7 +111,17 @@ RSpec.describe Ci::DailyBuildGroupReportResult do
...
@@ -101,7 +111,17 @@ RSpec.describe Ci::DailyBuildGroupReportResult do
project_count:
2
project_count:
2
)
)
expect
(
subject
).
to
contain_exactly
(
expected_results
)
expect
(
activity
).
to
contain_exactly
(
expected_results
)
end
context
'when coverage has more than 3 decimals'
do
let!
(
:coverage_3
)
do
create
(
:ci_daily_build_group_report_result
,
project:
project_2
,
group_name:
'cobertura'
,
coverage:
55.55555
)
end
it
'returns average_coverage with 2 decimals'
do
expect
(
activity
.
first
[
:average_coverage
]).
to
eq
(
69.85
)
end
end
end
end
end
...
...
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