summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-03-27 11:43:35 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-04-03 15:50:22 -0300
commit20486593bd0a3b0b150cb4b62edcb5eb7793297e (patch)
tree75255eebb75612441910e82fdea77d904d04a342
parent336ba94a7bbdd52f07d0f1c7f7bced20c37ad307 (diff)
downloadgitlab-ce-20486593bd0a3b0b150cb4b62edcb5eb7793297e.tar.gz
Skip MR metrics when importing projects from GitHub
-rw-r--r--app/models/concerns/importable.rb3
-rw-r--r--app/models/concerns/issuable.rb3
-rw-r--r--app/models/merge_request.rb1
-rw-r--r--lib/gitlab/github_import/pull_request_formatter.rb3
4 files changed, 7 insertions, 3 deletions
diff --git a/app/models/concerns/importable.rb b/app/models/concerns/importable.rb
index 019ef755849..8bce1c1766b 100644
--- a/app/models/concerns/importable.rb
+++ b/app/models/concerns/importable.rb
@@ -3,4 +3,7 @@ module Importable
attr_accessor :importing
alias_method :importing?, :importing
+
+ attr_accessor :skip_metrics
+ alias_method :skip_metrics?, :skip_metrics
end
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 4d54426b79e..863b43cec76 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -14,6 +14,7 @@ module Issuable
include Awardable
include Taskable
include TimeTrackable
+ include Importable
# This object is used to gather issuable meta data for displaying
# upvotes, downvotes, notes and closing merge requests count for issues and merge requests
@@ -99,7 +100,7 @@ module Issuable
acts_as_paranoid
after_save :update_assignee_cache_counts, if: :assignee_id_changed?
- after_save :record_metrics
+ after_save :record_metrics, unless: :skip_metrics?
def update_assignee_cache_counts
# make sure we flush the cache for both the old *and* new assignees(if they exist)
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 5ff83944d8c..8d740adb771 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -3,7 +3,6 @@ class MergeRequest < ActiveRecord::Base
include Issuable
include Referable
include Sortable
- include Importable
belongs_to :target_project, class_name: "Project"
belongs_to :source_project, class_name: "Project"
diff --git a/lib/gitlab/github_import/pull_request_formatter.rb b/lib/gitlab/github_import/pull_request_formatter.rb
index 38660a7ccca..b347e0b0feb 100644
--- a/lib/gitlab/github_import/pull_request_formatter.rb
+++ b/lib/gitlab/github_import/pull_request_formatter.rb
@@ -20,7 +20,8 @@ module Gitlab
author_id: author_id,
assignee_id: assignee_id,
created_at: raw_data.created_at,
- updated_at: raw_data.updated_at
+ updated_at: raw_data.updated_at,
+ skip_metrics: true
}
end