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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-11 15:09:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-11 15:09:26 +0300
commitc9687bdf58e9d4a9c3942f587bd4841f42e3b5de (patch)
treea60a2e20f152483be6a92bacdf10564bbc96c664 /app/services
parent3f3e4bcc50a3280d03299c2c263eafd9c8e3bd7b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/boards/issues/list_service.rb2
-rw-r--r--app/services/metrics/dashboard/grafana_metric_embed_service.rb20
2 files changed, 20 insertions, 2 deletions
diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb
index 699fa17cb65..337710b60e0 100644
--- a/app/services/boards/issues/list_service.rb
+++ b/app/services/boards/issues/list_service.rb
@@ -10,6 +10,8 @@ module Boards
end
def execute
+ return fetch_issues.order_closed_date_desc if list&.closed?
+
fetch_issues.order_by_position_and_priority(with_cte: can_attempt_search_optimization?)
end
diff --git a/app/services/metrics/dashboard/grafana_metric_embed_service.rb b/app/services/metrics/dashboard/grafana_metric_embed_service.rb
index 3ad3a2c609e..274057b8262 100644
--- a/app/services/metrics/dashboard/grafana_metric_embed_service.rb
+++ b/app/services/metrics/dashboard/grafana_metric_embed_service.rb
@@ -138,7 +138,9 @@ module Metrics
end
# Identifies the name of the datasource for a dashboard
- # based on the panelId query parameter found in the url
+ # based on the panelId query parameter found in the url.
+ #
+ # If no panel is specified, defaults to the first valid panel.
class DatasourceNameParser
def initialize(grafana_url, grafana_dashboard)
@grafana_url, @grafana_dashboard = grafana_url, grafana_dashboard
@@ -146,15 +148,29 @@ module Metrics
def parse
@grafana_dashboard[:dashboard][:panels]
- .find { |panel| panel[:id].to_s == query_params[:panelId] }
+ .find { |panel| panel_id ? matching_panel?(panel) : valid_panel?(panel) }
.try(:[], :datasource)
end
private
+ def panel_id
+ query_params[:panelId]
+ end
+
def query_params
Gitlab::Metrics::Dashboard::Url.parse_query(@grafana_url)
end
+
+ def matching_panel?(panel)
+ panel[:id].to_s == panel_id
+ end
+
+ def valid_panel?(panel)
+ ::Grafana::Validator
+ .new(@grafana_dashboard, nil, panel, query_params)
+ .valid?
+ end
end
end
end