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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
0f9bde41
Commit
0f9bde41
authored
Aug 01, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store & use ConvDev percentages returned by Version app
parent
28299de1
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
159 additions
and
16 deletions
+159
-16
app/models/conversational_development_index/metric.rb
app/models/conversational_development_index/metric.rb
+1
-3
app/services/submit_usage_ping_service.rb
app/services/submit_usage_ping_service.rb
+11
-9
changelogs/unreleased/35761-convdev-perc.yml
changelogs/unreleased/35761-convdev-perc.yml
+4
-0
db/migrate/20170731175128_add_percentages_to_conv_dev.rb
db/migrate/20170731175128_add_percentages_to_conv_dev.rb
+32
-0
db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb
...te/20170803090603_calculate_conv_dev_index_percentages.rb
+30
-0
db/schema.rb
db/schema.rb
+10
-0
spec/factories/conversational_development_index_metrics.rb
spec/factories/conversational_development_index_metrics.rb
+10
-0
spec/migrations/calculate_conv_dev_index_percentages_spec.rb
spec/migrations/calculate_conv_dev_index_percentages_spec.rb
+41
-0
spec/models/conversational_development_index/metric_spec.rb
spec/models/conversational_development_index/metric_spec.rb
+11
-0
spec/presenters/conversational_development_index/metric_presenter_spec.rb
...conversational_development_index/metric_presenter_spec.rb
+3
-3
spec/services/submit_usage_ping_service_spec.rb
spec/services/submit_usage_ping_service_spec.rb
+6
-1
No files found.
app/models/conversational_development_index/metric.rb
View file @
0f9bde41
...
...
@@ -13,9 +13,7 @@ module ConversationalDevelopmentIndex
end
def
percentage_score
(
feature
)
return
100
if
leader_score
(
feature
).
zero?
100
*
instance_score
(
feature
)
/
leader_score
(
feature
)
self
[
"percentage_
#{
feature
}
"
]
end
end
end
app/services/submit_usage_ping_service.rb
View file @
0f9bde41
class
SubmitUsagePingService
URL
=
'https://version.gitlab.com/usage_data'
.
freeze
METRICS
=
%w[leader_issues instance_issues percentage_issues leader_notes instance_notes
percentage_notes leader_milestones instance_milestones percentage_milestones
leader_boards instance_boards percentage_boards leader_merge_requests
instance_merge_requests percentage_merge_requests leader_ci_pipelines
instance_ci_pipelines percentage_ci_pipelines leader_environments instance_environments
percentage_environments leader_deployments instance_deployments percentage_deployments
leader_projects_prometheus_active instance_projects_prometheus_active
percentage_projects_prometheus_active leader_service_desk_issues instance_service_desk_issues
percentage_service_desk_issues]
.
freeze
include
Gitlab
::
CurrentSettings
def
execute
...
...
@@ -27,15 +37,7 @@ class SubmitUsagePingService
return
unless
response
[
'conv_index'
].
present?
ConversationalDevelopmentIndex
::
Metric
.
create!
(
response
[
'conv_index'
].
slice
(
'leader_issues'
,
'instance_issues'
,
'leader_notes'
,
'instance_notes'
,
'leader_milestones'
,
'instance_milestones'
,
'leader_boards'
,
'instance_boards'
,
'leader_merge_requests'
,
'instance_merge_requests'
,
'leader_ci_pipelines'
,
'instance_ci_pipelines'
,
'leader_environments'
,
'instance_environments'
,
'leader_deployments'
,
'instance_deployments'
,
'leader_projects_prometheus_active'
,
'instance_projects_prometheus_active'
,
'leader_service_desk_issues'
,
'instance_service_desk_issues'
)
response
[
'conv_index'
].
slice
(
*
METRICS
)
)
end
end
changelogs/unreleased/35761-convdev-perc.yml
0 → 100644
View file @
0f9bde41
---
title
:
Store & use ConvDev percentages returned by the Version app
merge_request
:
author
:
db/migrate/20170731175128_add_percentages_to_conv_dev.rb
0 → 100644
View file @
0f9bde41
class
AddPercentagesToConvDev
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
DOWNTIME
=
false
def
up
add_column_with_default
:conversational_development_index_metrics
,
:percentage_boards
,
:float
,
allow_null:
false
,
default:
0
add_column_with_default
:conversational_development_index_metrics
,
:percentage_ci_pipelines
,
:float
,
allow_null:
false
,
default:
0
add_column_with_default
:conversational_development_index_metrics
,
:percentage_deployments
,
:float
,
allow_null:
false
,
default:
0
add_column_with_default
:conversational_development_index_metrics
,
:percentage_environments
,
:float
,
allow_null:
false
,
default:
0
add_column_with_default
:conversational_development_index_metrics
,
:percentage_issues
,
:float
,
allow_null:
false
,
default:
0
add_column_with_default
:conversational_development_index_metrics
,
:percentage_merge_requests
,
:float
,
allow_null:
false
,
default:
0
add_column_with_default
:conversational_development_index_metrics
,
:percentage_milestones
,
:float
,
allow_null:
false
,
default:
0
add_column_with_default
:conversational_development_index_metrics
,
:percentage_notes
,
:float
,
allow_null:
false
,
default:
0
add_column_with_default
:conversational_development_index_metrics
,
:percentage_projects_prometheus_active
,
:float
,
allow_null:
false
,
default:
0
add_column_with_default
:conversational_development_index_metrics
,
:percentage_service_desk_issues
,
:float
,
allow_null:
false
,
default:
0
end
def
down
remove_column
:conversational_development_index_metrics
,
:percentage_boards
remove_column
:conversational_development_index_metrics
,
:percentage_ci_pipelines
remove_column
:conversational_development_index_metrics
,
:percentage_deployments
remove_column
:conversational_development_index_metrics
,
:percentage_environments
remove_column
:conversational_development_index_metrics
,
:percentage_issues
remove_column
:conversational_development_index_metrics
,
:percentage_merge_requests
remove_column
:conversational_development_index_metrics
,
:percentage_milestones
remove_column
:conversational_development_index_metrics
,
:percentage_notes
remove_column
:conversational_development_index_metrics
,
:percentage_projects_prometheus_active
remove_column
:conversational_development_index_metrics
,
:percentage_service_desk_issues
end
end
db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb
0 → 100644
View file @
0f9bde41
class
CalculateConvDevIndexPercentages
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
class
ConversationalDevelopmentIndexMetric
<
ActiveRecord
::
Base
self
.
table_name
=
'conversational_development_index_metrics'
METRICS
=
%w[boards ci_pipelines deployments environments issues merge_requests milestones notes
projects_prometheus_active service_desk_issues]
end
def
up
ConversationalDevelopmentIndexMetric
.
find_each
do
|
conv_dev_index
|
update
=
[]
ConversationalDevelopmentIndexMetric
::
METRICS
.
each
do
|
metric
|
instance_score
=
conv_dev_index
[
"instance_
#{
metric
}
"
].
to_f
leader_score
=
conv_dev_index
[
"leader_
#{
metric
}
"
].
to_f
percentage
=
leader_score
.
zero?
?
0.0
:
(
instance_score
/
leader_score
)
*
100
update
<<
"percentage_
#{
metric
}
= '
#{
percentage
}
'"
end
execute
(
"UPDATE conversational_development_index_metrics SET
#{
update
.
join
(
','
)
}
WHERE id =
#{
conv_dev_index
.
id
}
"
)
end
end
def
down
end
end
db/schema.rb
View file @
0f9bde41
...
...
@@ -451,6 +451,16 @@ ActiveRecord::Schema.define(version: 20170803130232) do
t
.
float
"instance_service_desk_issues"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
float
"percentage_boards"
,
default:
0.0
,
null:
false
t
.
float
"percentage_ci_pipelines"
,
default:
0.0
,
null:
false
t
.
float
"percentage_deployments"
,
default:
0.0
,
null:
false
t
.
float
"percentage_environments"
,
default:
0.0
,
null:
false
t
.
float
"percentage_issues"
,
default:
0.0
,
null:
false
t
.
float
"percentage_merge_requests"
,
default:
0.0
,
null:
false
t
.
float
"percentage_milestones"
,
default:
0.0
,
null:
false
t
.
float
"percentage_notes"
,
default:
0.0
,
null:
false
t
.
float
"percentage_projects_prometheus_active"
,
default:
0.0
,
null:
false
t
.
float
"percentage_service_desk_issues"
,
default:
0.0
,
null:
false
end
create_table
"deploy_keys_projects"
,
force: :cascade
do
|
t
|
...
...
spec/factories/conversational_development_index_metrics.rb
View file @
0f9bde41
...
...
@@ -2,32 +2,42 @@ FactoryGirl.define do
factory
:conversational_development_index_metric
,
class:
ConversationalDevelopmentIndex
::
Metric
do
leader_issues
9.256
instance_issues
1.234
percentage_issues
13.331
leader_notes
30.33333
instance_notes
28.123
percentage_notes
92.713
leader_milestones
16.2456
instance_milestones
1.234
percentage_milestones
7.595
leader_boards
5.2123
instance_boards
3.254
percentage_boards
62.429
leader_merge_requests
1.2
instance_merge_requests
0.6
percentage_merge_requests
50.0
leader_ci_pipelines
12.1234
instance_ci_pipelines
2.344
percentage_ci_pipelines
19.334
leader_environments
3.3333
instance_environments
2.2222
percentage_environments
66.672
leader_deployments
1.200
instance_deployments
0.771
percentage_deployments
64.25
leader_projects_prometheus_active
0.111
instance_projects_prometheus_active
0.109
percentage_projects_prometheus_active
98.198
leader_service_desk_issues
15.891
instance_service_desk_issues
13.345
percentage_service_desk_issues
83.978
end
end
spec/migrations/calculate_conv_dev_index_percentages_spec.rb
0 → 100644
View file @
0f9bde41
# encoding: utf-8
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20170803090603_calculate_conv_dev_index_percentages.rb'
)
describe
CalculateConvDevIndexPercentages
,
truncate:
true
do
let
(
:migration
)
{
described_class
.
new
}
let!
(
:conv_dev_index
)
do
create
(
:conversational_development_index_metric
,
leader_notes:
0
,
instance_milestones:
0
,
percentage_issues:
0
,
percentage_notes:
0
,
percentage_milestones:
0
,
percentage_boards:
0
,
percentage_merge_requests:
0
,
percentage_ci_pipelines:
0
,
percentage_environments:
0
,
percentage_deployments:
0
,
percentage_projects_prometheus_active:
0
,
percentage_service_desk_issues:
0
)
end
describe
'#up'
do
it
'calculates percentages correctly'
do
migration
.
up
conv_dev_index
.
reload
expect
(
conv_dev_index
.
percentage_issues
).
to
be_within
(
0.1
).
of
(
13.3
)
expect
(
conv_dev_index
.
percentage_notes
).
to
be_zero
# leader 0
expect
(
conv_dev_index
.
percentage_milestones
).
to
be_zero
# instance 0
expect
(
conv_dev_index
.
percentage_boards
).
to
be_within
(
0.1
).
of
(
62.4
)
expect
(
conv_dev_index
.
percentage_merge_requests
).
to
eq
(
50.0
)
expect
(
conv_dev_index
.
percentage_ci_pipelines
).
to
be_within
(
0.1
).
of
(
19.3
)
expect
(
conv_dev_index
.
percentage_environments
).
to
be_within
(
0.1
).
of
(
66.7
)
expect
(
conv_dev_index
.
percentage_deployments
).
to
be_within
(
0.1
).
of
(
64.2
)
expect
(
conv_dev_index
.
percentage_projects_prometheus_active
).
to
be_within
(
0.1
).
of
(
98.2
)
expect
(
conv_dev_index
.
percentage_service_desk_issues
).
to
be_within
(
0.1
).
of
(
84.0
)
end
end
end
spec/models/conversational_development_index/metric_spec.rb
0 → 100644
View file @
0f9bde41
require
'rails_helper'
describe
ConversationalDevelopmentIndex
::
Metric
do
let
(
:conv_dev_index
)
{
create
(
:conversational_development_index_metric
)
}
describe
'#percentage_score'
do
it
'returns stored percentage score'
do
expect
(
conv_dev_index
.
percentage_score
(
'issues'
)).
to
eq
(
13.331
)
end
end
end
spec/presenters/conversational_development_index/metric_presenter_spec.rb
View file @
0f9bde41
...
...
@@ -8,9 +8,9 @@ describe ConversationalDevelopmentIndex::MetricPresenter do
it
'includes instance score, leader score and percentage score'
do
issues_card
=
subject
.
cards
.
first
expect
(
issues_card
.
instance_score
).
to
eq
1.234
expect
(
issues_card
.
leader_score
).
to
eq
9.256
expect
(
issues_card
.
percentage_score
).
to
be_within
(
0.1
).
of
(
13.3
)
expect
(
issues_card
.
instance_score
).
to
eq
(
1.234
)
expect
(
issues_card
.
leader_score
).
to
eq
(
9.256
)
expect
(
issues_card
.
percentage_score
).
to
eq
(
13.331
)
end
end
...
...
spec/services/submit_usage_ping_service_spec.rb
View file @
0f9bde41
...
...
@@ -46,6 +46,8 @@ describe SubmitUsagePingService do
.
by
(
1
)
expect
(
ConversationalDevelopmentIndex
::
Metric
.
last
.
leader_issues
).
to
eq
10.2
expect
(
ConversationalDevelopmentIndex
::
Metric
.
last
.
instance_issues
).
to
eq
3.2
expect
(
ConversationalDevelopmentIndex
::
Metric
.
last
.
percentage_issues
).
to
eq
31.37
end
end
...
...
@@ -60,6 +62,7 @@ describe SubmitUsagePingService do
conv_index:
{
leader_issues:
10.2
,
instance_issues:
3.2
,
percentage_issues:
31.37
,
leader_notes:
25.3
,
instance_notes:
23.2
,
...
...
@@ -86,7 +89,9 @@ describe SubmitUsagePingService do
instance_projects_prometheus_active:
0.30
,
leader_service_desk_issues:
15.8
,
instance_service_desk_issues:
15.1
instance_service_desk_issues:
15.1
,
non_existing_column:
'value'
}
}
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