diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/environments/folder/environments_folder_view.vue | 12 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/environments.scss | 1 | ||||
-rw-r--r-- | app/models/ci/build_trace_section.rb | 3 | ||||
-rw-r--r-- | app/models/merge_request.rb | 9 | ||||
-rw-r--r-- | app/models/merge_request_diff.rb | 11 | ||||
-rw-r--r-- | app/models/project.rb | 23 | ||||
-rw-r--r-- | app/services/merge_requests/refresh_service.rb | 2 | ||||
-rw-r--r-- | app/services/metrics/dashboard/base_embed_service.rb | 2 | ||||
-rw-r--r-- | app/services/metrics/dashboard/custom_metric_embed_service.rb | 2 | ||||
-rw-r--r-- | app/services/metrics/dashboard/predefined_dashboard_service.rb | 45 | ||||
-rw-r--r-- | app/services/metrics/dashboard/system_dashboard_service.rb | 37 | ||||
-rw-r--r-- | app/views/projects/environments/folder.html.haml | 4 |
12 files changed, 80 insertions, 71 deletions
diff --git a/app/assets/javascripts/environments/folder/environments_folder_view.vue b/app/assets/javascripts/environments/folder/environments_folder_view.vue index 6fd0561f682..d60c2efd618 100644 --- a/app/assets/javascripts/environments/folder/environments_folder_view.vue +++ b/app/assets/javascripts/environments/folder/environments_folder_view.vue @@ -40,13 +40,13 @@ export default { <div :class="cssContainerClass"> <stop-environment-modal :environment="environmentInStopModal" /> - <div v-if="!isLoading" class="top-area"> - <h4 class="js-folder-name environments-folder-name"> - {{ s__('Environments|Environments') }} / - <b>{{ folderName }}</b> - </h4> + <h4 class="js-folder-name environments-folder-name"> + {{ s__('Environments|Environments') }} / + <b>{{ folderName }}</b> + </h4> - <tabs :tabs="tabs" scope="environments" @onChangeTab="onChangeTab" /> + <div class="top-area"> + <tabs v-if="!isLoading" :tabs="tabs" scope="environments" @onChangeTab="onChangeTab" /> </div> <container diff --git a/app/assets/stylesheets/pages/environments.scss b/app/assets/stylesheets/pages/environments.scss index 93dffb5ff09..3892d9dbd07 100644 --- a/app/assets/stylesheets/pages/environments.scss +++ b/app/assets/stylesheets/pages/environments.scss @@ -7,7 +7,6 @@ .environments-folder-name { font-weight: $gl-font-weight-normal; - padding-top: 20px; } .environments-container { diff --git a/app/models/ci/build_trace_section.rb b/app/models/ci/build_trace_section.rb index 7fe6b753da1..8be42eb48d6 100644 --- a/app/models/ci/build_trace_section.rb +++ b/app/models/ci/build_trace_section.rb @@ -4,9 +4,6 @@ module Ci class BuildTraceSection < ApplicationRecord extend Gitlab::Ci::Model - # Only remove > 2019-11-22 and > 12.5 - self.ignored_columns += %i[id] - belongs_to :build, class_name: 'Ci::Build' belongs_to :project belongs_to :section_name, class_name: 'Ci::BuildTraceSectionName' diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 93234cbdfe1..16d36d42eac 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -420,15 +420,6 @@ class MergeRequest < ApplicationRecord limit ? shas.take(limit) : shas end - # Returns true if there are commits that match at least one commit SHA. - def includes_any_commits?(shas) - if persisted? - merge_request_diff.commits_by_shas(shas).exists? - else - (commit_shas & shas).present? - end - end - def supports_suggestion? true end diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index e91a529fecc..06a9a6ee873 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -10,6 +10,7 @@ class MergeRequestDiff < ApplicationRecord # Don't display more than 100 commits at once COMMITS_SAFE_SIZE = 100 + BATCH_SIZE = 1000 # Applies to closed or merged MRs when determining whether to migrate their # diffs to external storage @@ -254,10 +255,14 @@ class MergeRequestDiff < ApplicationRecord merge_request_diff_commits.limit(limit).pluck(:sha) end - def commits_by_shas(shas) - return MergeRequestDiffCommit.none unless shas.present? + def includes_any_commits?(shas) + return false if shas.blank? - merge_request_diff_commits.where(sha: shas) + # when the number of shas is huge (1000+) we don't want + # to pass them all as an SQL param, let's pass them in batches + shas.each_slice(BATCH_SIZE).any? do |batched_shas| + merge_request_diff_commits.where(sha: batched_shas).exists? + end end def diff_refs=(new_diff_refs) diff --git a/app/models/project.rb b/app/models/project.rb index 0887e742d96..67225d7fb78 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -62,20 +62,6 @@ class Project < ApplicationRecord cache_markdown_field :description, pipeline: :description - delegate :feature_available?, :builds_enabled?, :wiki_enabled?, :merge_requests_enabled?, - :issues_enabled?, :pages_enabled?, :public_pages?, :private_pages?, - :merge_requests_access_level, :issues_access_level, :wiki_access_level, - :snippets_access_level, :builds_access_level, :repository_access_level, - to: :project_feature, allow_nil: true - - delegate :base_dir, :disk_path, to: :storage - - delegate :scheduled?, :started?, :in_progress?, - :failed?, :finished?, - prefix: :import, to: :import_state, allow_nil: true - - delegate :no_import?, to: :import_state, allow_nil: true - # TODO: remove once GitLab 12.5 is released # https://gitlab.com/gitlab-org/gitlab/issues/34638 self.ignored_columns += %i[merge_requests_require_code_owner_approval] @@ -323,6 +309,15 @@ class Project < ApplicationRecord accepts_nested_attributes_for :metrics_setting, update_only: true, allow_destroy: true accepts_nested_attributes_for :grafana_integration, update_only: true, allow_destroy: true + delegate :feature_available?, :builds_enabled?, :wiki_enabled?, :merge_requests_enabled?, + :issues_enabled?, :pages_enabled?, :public_pages?, :private_pages?, + :merge_requests_access_level, :issues_access_level, :wiki_access_level, + :snippets_access_level, :builds_access_level, :repository_access_level, + to: :project_feature, allow_nil: true + delegate :scheduled?, :started?, :in_progress?, :failed?, :finished?, + prefix: :import, to: :import_state, allow_nil: true + delegate :base_dir, :disk_path, to: :storage + delegate :no_import?, to: :import_state, allow_nil: true delegate :name, to: :owner, allow_nil: true, prefix: true delegate :members, to: :team, prefix: true delegate :add_user, :add_users, to: :team diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index bd3fcf85a62..396ddec6383 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -106,7 +106,7 @@ module MergeRequests filter_merge_requests(merge_requests).each do |merge_request| if branch_and_project_match?(merge_request) || @push.force_push? merge_request.reload_diff(current_user) - elsif merge_request.includes_any_commits?(push_commit_ids) + elsif merge_request.merge_request_diff.includes_any_commits?(push_commit_ids) merge_request.reload_diff(current_user) end diff --git a/app/services/metrics/dashboard/base_embed_service.rb b/app/services/metrics/dashboard/base_embed_service.rb index 8bb5f4892cb..8aef9873ac1 100644 --- a/app/services/metrics/dashboard/base_embed_service.rb +++ b/app/services/metrics/dashboard/base_embed_service.rb @@ -13,7 +13,7 @@ module Metrics def dashboard_path params[:dashboard_path].presence || - ::Metrics::Dashboard::SystemDashboardService::SYSTEM_DASHBOARD_PATH + ::Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH end def group diff --git a/app/services/metrics/dashboard/custom_metric_embed_service.rb b/app/services/metrics/dashboard/custom_metric_embed_service.rb index 79a556b1695..9e616f4e379 100644 --- a/app/services/metrics/dashboard/custom_metric_embed_service.rb +++ b/app/services/metrics/dashboard/custom_metric_embed_service.rb @@ -40,7 +40,7 @@ module Metrics # All custom metrics are displayed on the system dashboard. # Nil is acceptable as we'll default to the system dashboard. def valid_dashboard?(dashboard) - dashboard.nil? || ::Metrics::Dashboard::SystemDashboardService.system_dashboard?(dashboard) + dashboard.nil? || ::Metrics::Dashboard::SystemDashboardService.matching_dashboard?(dashboard) end end diff --git a/app/services/metrics/dashboard/predefined_dashboard_service.rb b/app/services/metrics/dashboard/predefined_dashboard_service.rb new file mode 100644 index 00000000000..1be1a000854 --- /dev/null +++ b/app/services/metrics/dashboard/predefined_dashboard_service.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +module Metrics + module Dashboard + class PredefinedDashboardService < ::Metrics::Dashboard::BaseService + # These constants should be overridden in the inheriting class. For Ex: + # DASHBOARD_PATH = 'config/prometheus/common_metrics.yml' + # DASHBOARD_NAME = 'Default' + DASHBOARD_PATH = nil + DASHBOARD_NAME = nil + + SEQUENCE = [ + STAGES::EndpointInserter, + STAGES::Sorter + ].freeze + + class << self + def matching_dashboard?(filepath) + filepath == self::DASHBOARD_PATH + end + end + + private + + def cache_key + "metrics_dashboard_#{dashboard_path}" + end + + def dashboard_path + self.class::DASHBOARD_PATH + end + + # Returns the base metrics shipped with every GitLab service. + def get_raw_dashboard + yml = File.read(Rails.root.join(dashboard_path)) + + YAML.safe_load(yml) + end + + def sequence + self.class::SEQUENCE + end + end + end +end diff --git a/app/services/metrics/dashboard/system_dashboard_service.rb b/app/services/metrics/dashboard/system_dashboard_service.rb index f8dbb8a705c..bef65dbe1c2 100644 --- a/app/services/metrics/dashboard/system_dashboard_service.rb +++ b/app/services/metrics/dashboard/system_dashboard_service.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true # Fetches the system metrics dashboard and formats the output. -# Use Gitlab::Metrics::Dashboard::Finder to retrive dashboards. +# Use Gitlab::Metrics::Dashboard::Finder to retrieve dashboards. module Metrics module Dashboard - class SystemDashboardService < ::Metrics::Dashboard::BaseService - SYSTEM_DASHBOARD_PATH = 'config/prometheus/common_metrics.yml' - SYSTEM_DASHBOARD_NAME = 'Default' + class SystemDashboardService < ::Metrics::Dashboard::PredefinedDashboardService + DASHBOARD_PATH = 'config/prometheus/common_metrics.yml' + DASHBOARD_NAME = 'Default' SEQUENCE = [ STAGES::CommonMetricsInserter, @@ -18,37 +18,12 @@ module Metrics class << self def all_dashboard_paths(_project) [{ - path: SYSTEM_DASHBOARD_PATH, - display_name: SYSTEM_DASHBOARD_NAME, + path: DASHBOARD_PATH, + display_name: DASHBOARD_NAME, default: true, system_dashboard: true }] end - - def system_dashboard?(filepath) - filepath == SYSTEM_DASHBOARD_PATH - end - end - - private - - def cache_key - "metrics_dashboard_#{dashboard_path}" - end - - def dashboard_path - SYSTEM_DASHBOARD_PATH - end - - # Returns the base metrics shipped with every GitLab service. - def get_raw_dashboard - yml = File.read(Rails.root.join(dashboard_path)) - - YAML.safe_load(yml) - end - - def sequence - SEQUENCE end end end diff --git a/app/views/projects/environments/folder.html.haml b/app/views/projects/environments/folder.html.haml index f85c57d9aa1..cd24c30e46f 100644 --- a/app/views/projects/environments/folder.html.haml +++ b/app/views/projects/environments/folder.html.haml @@ -1,3 +1,5 @@ -- page_title _("Environments") +- add_to_breadcrumbs _("Environments"), project_environments_path(@project) +- breadcrumb_title _("Folder/%{name}") % { name: @folder } +- page_title _("Environments in %{name}") % { name: @folder } #environments-folder-list-view{ data: { environments_data: environments_folder_list_view_data } } |