summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-08-01 08:46:43 +0200
committerJarka Kadlecova <jarka@gitlab.com>2017-08-07 20:52:08 +0200
commit0f9bde41fc5d51ef227021444e2185fb5e5162f1 (patch)
tree0d1f5959c3464aff053751f99f11bf2319d5ce7a /db
parent28299de189c4c1e9c900d68f98ecfac993cb0aed (diff)
downloadgitlab-ce-0f9bde41fc5d51ef227021444e2185fb5e5162f1.tar.gz
Store & use ConvDev percentages returned by Version app35761-convdev-perc
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170731175128_add_percentages_to_conv_dev.rb32
-rw-r--r--db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb30
-rw-r--r--db/schema.rb10
3 files changed, 72 insertions, 0 deletions
diff --git a/db/migrate/20170731175128_add_percentages_to_conv_dev.rb b/db/migrate/20170731175128_add_percentages_to_conv_dev.rb
new file mode 100644
index 00000000000..1819bfc96bb
--- /dev/null
+++ b/db/migrate/20170731175128_add_percentages_to_conv_dev.rb
@@ -0,0 +1,32 @@
+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
diff --git a/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb
new file mode 100644
index 00000000000..9af76c94bf3
--- /dev/null
+++ b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb
@@ -0,0 +1,30 @@
+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
diff --git a/db/schema.rb b/db/schema.rb
index f2f35acef95..dc5640ad2ca 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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|