Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 12:08:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-02 12:08:14 +0300
commitade18c9d68d5a2e6c6e28ef7e9d3add3b3491ace (patch)
treecf4154332fc95283f58cccb1383e43b40485d91d /app
parentba836d98593d68d8d6c22c540e31c8031a786bd8 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/blob_controller.rb14
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--app/serializers/diff_file_entity.rb4
-rw-r--r--app/serializers/diffs_entity.rb10
-rw-r--r--app/serializers/paginated_diff_entity.rb6
-rw-r--r--app/services/metrics/dashboard/base_service.rb47
-rw-r--r--app/views/projects/blob/_blob.html.haml5
7 files changed, 65 insertions, 23 deletions
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index 8c8824ae47f..584320a66de 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -208,24 +208,12 @@ class Projects::BlobController < Projects::ApplicationController
.last_for_path(@repository, @ref, @path).sha
end
- def set_code_navigation_build
- return if Feature.disabled?(:code_navigation, @project)
-
- artifact =
- Ci::JobArtifact
- .for_sha(@blob.commit_id, @project.id)
- .for_job_name(Ci::Build::CODE_NAVIGATION_JOB_NAME)
- .last
-
- @code_navigation_build = artifact&.job
- end
-
def show_html
environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit }
environment_params[:find_latest] = true
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last
@last_commit = @repository.last_commit_for_path(@commit.id, @blob.path)
- set_code_navigation_build
+ @code_navigation_path = Gitlab::CodeNavigationPath.new(@project, @blob.commit_id).full_json_path_for(@blob.path)
render 'show'
end
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 5b794f7ccf0..74a329dccf4 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -33,8 +33,6 @@ module Ci
scheduler_failure: 2
}.freeze
- CODE_NAVIGATION_JOB_NAME = 'code_navigation'
-
has_one :deployment, as: :deployable, class_name: 'Deployment'
has_one :resource, class_name: 'Ci::Resource', inverse_of: :build
has_many :trace_sections, class_name: 'Ci::BuildTraceSection'
diff --git a/app/serializers/diff_file_entity.rb b/app/serializers/diff_file_entity.rb
index 45c16aabe9e..26a42d2e9eb 100644
--- a/app/serializers/diff_file_entity.rb
+++ b/app/serializers/diff_file_entity.rb
@@ -64,6 +64,10 @@ class DiffFileEntity < DiffFileBaseEntity
# Used for parallel diffs
expose :parallel_diff_lines, using: DiffLineParallelEntity, if: -> (diff_file, options) { parallel_diff_view?(options, diff_file) && diff_file.text? }
+ expose :code_navigation_path, if: -> (diff_file) { options[:code_navigation_path] } do |diff_file|
+ options[:code_navigation_path].full_json_path_for(diff_file.new_path)
+ end
+
private
def parallel_diff_view?(options, diff_file)
diff --git a/app/serializers/diffs_entity.rb b/app/serializers/diffs_entity.rb
index 02f78180fb0..b709fc7228b 100644
--- a/app/serializers/diffs_entity.rb
+++ b/app/serializers/diffs_entity.rb
@@ -70,13 +70,21 @@ class DiffsEntity < Grape::Entity
expose :diff_files do |diffs, options|
submodule_links = Gitlab::SubmoduleLinks.new(merge_request.project.repository)
- DiffFileEntity.represent(diffs.diff_files, options.merge(submodule_links: submodule_links))
+ code_navigation_path =
+ Gitlab::CodeNavigationPath.new(merge_request.project, diffs.diff_refs.head_sha)
+
+ DiffFileEntity.represent(diffs.diff_files,
+ options.merge(submodule_links: submodule_links, code_navigation_path: code_navigation_path))
end
expose :merge_request_diffs, using: MergeRequestDiffEntity, if: -> (_, options) { options[:merge_request_diffs]&.any? } do |diffs|
options[:merge_request_diffs]
end
+ expose :definition_path_prefix, if: -> (diff_file) { Feature.enabled?(:code_navigation, merge_request.project) } do |diffs|
+ project_blob_path(merge_request.project, diffs.diff_refs.head_sha)
+ end
+
def merge_request
options[:merge_request]
end
diff --git a/app/serializers/paginated_diff_entity.rb b/app/serializers/paginated_diff_entity.rb
index 622da926c69..a31c9d70d4b 100644
--- a/app/serializers/paginated_diff_entity.rb
+++ b/app/serializers/paginated_diff_entity.rb
@@ -10,7 +10,11 @@ class PaginatedDiffEntity < Grape::Entity
expose :diff_files do |diffs, options|
submodule_links = Gitlab::SubmoduleLinks.new(merge_request.project.repository)
- DiffFileEntity.represent(diffs.diff_files, options.merge(submodule_links: submodule_links))
+ code_navigation_path =
+ Gitlab::CodeNavigationPath.new(merge_request.project, diffs.diff_refs.head_sha)
+
+ DiffFileEntity.represent(diffs.diff_files,
+ options.merge(submodule_links: submodule_links, code_navigation_path: code_navigation_path))
end
expose :pagination do
diff --git a/app/services/metrics/dashboard/base_service.rb b/app/services/metrics/dashboard/base_service.rb
index 3cd7d8437b1..a19f3f78b3d 100644
--- a/app/services/metrics/dashboard/base_service.rb
+++ b/app/services/metrics/dashboard/base_service.rb
@@ -45,9 +45,30 @@ module Metrics
# Returns a new dashboard Hash, supplemented with DB info
def process_dashboard
- ::Gitlab::Metrics::Dashboard::Processor
- .new(project, raw_dashboard, sequence, process_params)
- .process
+ # Get the dashboard from cache/disk before beginning the benchmark.
+ dashboard = raw_dashboard
+ processed_dashboard = nil
+
+ benchmark_processing do
+ processed_dashboard = ::Gitlab::Metrics::Dashboard::Processor
+ .new(project, dashboard, sequence, process_params)
+ .process
+ end
+
+ processed_dashboard
+ end
+
+ def benchmark_processing
+ output = nil
+
+ processing_time_seconds = Benchmark.realtime { output = yield }
+
+ if output
+ processing_time_metric.observe(
+ processing_time_metric_labels,
+ processing_time_seconds * 1_000
+ )
+ end
end
def process_params
@@ -72,6 +93,26 @@ module Metrics
def sequence
SEQUENCE
end
+
+ def processing_time_metric
+ @processing_time_metric ||= ::Gitlab::Metrics.summary(
+ :gitlab_metrics_dashboard_processing_time_ms,
+ 'Metrics dashboard processing time in milliseconds'
+ )
+ end
+
+ def processing_time_metric_labels
+ {
+ stages: sequence_string,
+ service: self.class.name
+ }
+ end
+
+ # If @sequence is [STAGES::CommonMetricsInserter, STAGES::CustomMetricsInserter],
+ # this function will output `CommonMetricsInserter-CustomMetricsInserter`.
+ def sequence_string
+ sequence.map { |stage_class| stage_class.to_s.split('::').last }.join('-')
+ end
end
end
end
diff --git a/app/views/projects/blob/_blob.html.haml b/app/views/projects/blob/_blob.html.haml
index 02a327c5a49..8e8a6b847df 100644
--- a/app/views/projects/blob/_blob.html.haml
+++ b/app/views/projects/blob/_blob.html.haml
@@ -9,9 +9,8 @@
= render "projects/blob/auxiliary_viewer", blob: blob
#blob-content-holder.blob-content-holder
- - if @code_navigation_build
- - code_nav_url = raw_project_job_artifacts_url(@project, @code_navigation_build, path: "lsif/#{blob.path}")
- #js-code-navigation{ data: { code_nav_url: "#{code_nav_url}.json", definition_path_prefix: project_blob_path(@project, @ref) } }
+ - if @code_navigation_path
+ #js-code-navigation{ data: { code_nav_url: @code_navigation_path, definition_path_prefix: project_blob_path(@project, @ref) } }
%article.file-holder
= render 'projects/blob/header', blob: blob
= render 'projects/blob/content', blob: blob