summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ci/reports/codequality_reports_comparer.rb8
-rw-r--r--lib/gitlab/ci/reports/reports_comparer.rb10
-rw-r--r--lib/gitlab/github_import/importer/pull_request_review_importer.rb18
-rw-r--r--lib/gitlab/usage_data.rb14
-rw-r--r--lib/gitlab/usage_data_counters/aggregated_metrics/code_review.yml8
-rw-r--r--lib/gitlab/usage_data_counters/known_events/code_review_events.yml10
-rw-r--r--lib/gitlab/usage_data_counters/merge_request_activity_unique_counter.rb10
7 files changed, 67 insertions, 11 deletions
diff --git a/lib/gitlab/ci/reports/codequality_reports_comparer.rb b/lib/gitlab/ci/reports/codequality_reports_comparer.rb
index 88e02cd9004..10748b8ca02 100644
--- a/lib/gitlab/ci/reports/codequality_reports_comparer.rb
+++ b/lib/gitlab/ci/reports/codequality_reports_comparer.rb
@@ -5,7 +5,7 @@ module Gitlab
module Reports
class CodequalityReportsComparer < ReportsComparer
def initialize(base_report, head_report)
- @base_report = base_report || CodequalityReports.new
+ @base_report = base_report
@head_report = head_report
end
@@ -15,12 +15,16 @@ module Gitlab
def existing_errors
strong_memoize(:existing_errors) do
+ next [] if not_found?
+
base_report.all_degradations & head_report.all_degradations
end
end
def new_errors
strong_memoize(:new_errors) do
+ next [] if not_found?
+
fingerprints = head_report.degradations.keys - base_report.degradations.keys
head_report.degradations.fetch_values(*fingerprints)
end
@@ -28,6 +32,8 @@ module Gitlab
def resolved_errors
strong_memoize(:resolved_errors) do
+ next [] if not_found?
+
fingerprints = base_report.degradations.keys - head_report.degradations.keys
base_report.degradations.fetch_values(*fingerprints)
end
diff --git a/lib/gitlab/ci/reports/reports_comparer.rb b/lib/gitlab/ci/reports/reports_comparer.rb
index 5667998e535..16a7f6478b7 100644
--- a/lib/gitlab/ci/reports/reports_comparer.rb
+++ b/lib/gitlab/ci/reports/reports_comparer.rb
@@ -18,10 +18,10 @@ module Gitlab
end
def status
- if success?
- STATUS_SUCCESS
- elsif base_report.nil? || head_report.nil?
+ if base_report.nil? || head_report.nil?
STATUS_NOT_FOUND
+ elsif success?
+ STATUS_SUCCESS
else
STATUS_FAILED
end
@@ -54,6 +54,10 @@ module Gitlab
def total_count
existing_errors.size + new_errors.size
end
+
+ def not_found?
+ status == STATUS_NOT_FOUND
+ end
end
end
end
diff --git a/lib/gitlab/github_import/importer/pull_request_review_importer.rb b/lib/gitlab/github_import/importer/pull_request_review_importer.rb
index 14ee69ba089..9f495913897 100644
--- a/lib/gitlab/github_import/importer/pull_request_review_importer.rb
+++ b/lib/gitlab/github_import/importer/pull_request_review_importer.rb
@@ -77,12 +77,22 @@ module Gitlab
def add_approval!(user_id)
return unless review.review_type == 'APPROVED'
- add_approval_system_note!(user_id)
-
- merge_request.approvals.create!(
+ approval_attribues = {
+ merge_request_id: merge_request.id,
user_id: user_id,
- created_at: review.submitted_at
+ created_at: review.submitted_at,
+ updated_at: review.submitted_at
+ }
+
+ result = ::Approval.insert(
+ approval_attribues,
+ returning: [:id],
+ unique_by: [:user_id, :merge_request_id]
)
+
+ if result.rows.present?
+ add_approval_system_note!(user_id)
+ end
end
def add_approval_system_note!(user_id)
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 500c4ab17c6..32b67a73fa3 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -242,7 +242,8 @@ module Gitlab
def system_usage_data_settings
{
settings: {
- ldap_encrypted_secrets_enabled: alt_usage_data(fallback: nil) { Gitlab::Auth::Ldap::Config.encrypted_secrets.active? }
+ ldap_encrypted_secrets_enabled: alt_usage_data(fallback: nil) { Gitlab::Auth::Ldap::Config.encrypted_secrets.active? },
+ operating_system: alt_usage_data(fallback: nil) { operating_system }
}
}
end
@@ -505,6 +506,17 @@ module Gitlab
end
end
+ def operating_system
+ ohai_data = Ohai::System.new.tap do |oh|
+ oh.all_plugins(['platform'])
+ end.data
+
+ platform = ohai_data['platform']
+ platform = 'raspbian' if ohai_data['platform'] == 'debian' && /armv/.match?(ohai_data['kernel']['machine'])
+
+ "#{platform}-#{ohai_data['platform_version']}"
+ end
+
def last_28_days_time_period(column: :created_at)
{ column => 30.days.ago..2.days.ago }
end
diff --git a/lib/gitlab/usage_data_counters/aggregated_metrics/code_review.yml b/lib/gitlab/usage_data_counters/aggregated_metrics/code_review.yml
index c856d0a5eee..f19de850490 100644
--- a/lib/gitlab/usage_data_counters/aggregated_metrics/code_review.yml
+++ b/lib/gitlab/usage_data_counters/aggregated_metrics/code_review.yml
@@ -44,7 +44,9 @@
'i_code_review_user_toggled_task_item_status',
'i_code_review_user_create_mr_from_issue',
'i_code_review_user_mr_discussion_locked',
- 'i_code_review_user_mr_discussion_unlocked'
+ 'i_code_review_user_mr_discussion_unlocked',
+ 'i_code_review_user_time_estimate_changed',
+ 'i_code_review_user_time_spent_changed'
]
- name: code_review_category_monthly_active_users
operator: OR
@@ -82,7 +84,9 @@
'i_code_review_user_toggled_task_item_status',
'i_code_review_user_create_mr_from_issue',
'i_code_review_user_mr_discussion_locked',
- 'i_code_review_user_mr_discussion_unlocked'
+ 'i_code_review_user_mr_discussion_unlocked',
+ 'i_code_review_user_time_estimate_changed',
+ 'i_code_review_user_time_spent_changed'
]
- name: code_review_extension_category_monthly_active_users
operator: OR
diff --git a/lib/gitlab/usage_data_counters/known_events/code_review_events.yml b/lib/gitlab/usage_data_counters/known_events/code_review_events.yml
index 21613740142..83a932456f9 100644
--- a/lib/gitlab/usage_data_counters/known_events/code_review_events.yml
+++ b/lib/gitlab/usage_data_counters/known_events/code_review_events.yml
@@ -174,3 +174,13 @@
category: code_review
aggregation: weekly
feature_flag: usage_data_i_code_review_user_mr_discussion_unlocked
+- name: i_code_review_user_time_estimate_changed
+ redis_slot: code_review
+ category: code_review
+ aggregation: weekly
+ feature_flag: usage_data_i_code_review_user_time_estimate_changed
+- name: i_code_review_user_time_spent_changed
+ redis_slot: code_review
+ category: code_review
+ aggregation: weekly
+ feature_flag: usage_data_i_code_review_user_time_spent_changed
diff --git a/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter.rb b/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter.rb
index b94caa32bf7..daa4c34ae1f 100644
--- a/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter.rb
+++ b/lib/gitlab/usage_data_counters/merge_request_activity_unique_counter.rb
@@ -37,6 +37,8 @@ module Gitlab
MR_CREATE_FROM_ISSUE_ACTION = 'i_code_review_user_create_mr_from_issue'
MR_DISCUSSION_LOCKED_ACTION = 'i_code_review_user_mr_discussion_locked'
MR_DISCUSSION_UNLOCKED_ACTION = 'i_code_review_user_mr_discussion_unlocked'
+ MR_TIME_ESTIMATE_CHANGED_ACTION = 'i_code_review_user_time_estimate_changed'
+ MR_TIME_SPENT_CHANGED_ACTION = 'i_code_review_user_time_spent_changed'
class << self
def track_mr_diffs_action(merge_request:)
@@ -163,6 +165,14 @@ module Gitlab
track_unique_action_by_user(MR_DISCUSSION_UNLOCKED_ACTION, user)
end
+ def track_time_estimate_changed_action(user:)
+ track_unique_action_by_user(MR_TIME_ESTIMATE_CHANGED_ACTION, user)
+ end
+
+ def track_time_spent_changed_action(user:)
+ track_unique_action_by_user(MR_TIME_SPENT_CHANGED_ACTION, user)
+ end
+
private
def track_unique_action_by_merge_request(action, merge_request)