diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-07 21:07:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-07 21:07:54 +0000 |
commit | 8c8b94e7116fa478ad490bd14c09565d23097f57 (patch) | |
tree | 9e4637aa0fe498a5523c86932b87ff691ec72af6 /lib/gitlab | |
parent | eadb77d89f5f7d445bfd326f18873168f4719f12 (diff) | |
download | gitlab-ce-8c8b94e7116fa478ad490bd14c09565d23097f57.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/badge/pipeline/template.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/status/preparing.rb | 12 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/base_query.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/issue_helper.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/plan_helper.rb | 5 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/stage_summary.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/summary/base.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/summary/commit.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/summary/deploy.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/summary/issue.rb | 5 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client/storage_settings.rb | 2 |
11 files changed, 32 insertions, 28 deletions
diff --git a/lib/gitlab/badge/pipeline/template.rb b/lib/gitlab/badge/pipeline/template.rb index 2c5f9654496..0d3d44135e7 100644 --- a/lib/gitlab/badge/pipeline/template.rb +++ b/lib/gitlab/badge/pipeline/template.rb @@ -15,7 +15,7 @@ module Gitlab failed: '#e05d44', running: '#dfb317', pending: '#dfb317', - preparing: '#dfb317', + preparing: '#a7a7a7', canceled: '#9f9f9f', skipped: '#9f9f9f', unknown: '#9f9f9f' diff --git a/lib/gitlab/ci/status/preparing.rb b/lib/gitlab/ci/status/preparing.rb index 62985d0a9f9..1ebdbc482b7 100644 --- a/lib/gitlab/ci/status/preparing.rb +++ b/lib/gitlab/ci/status/preparing.rb @@ -12,20 +12,12 @@ module Gitlab s_('CiStatusLabel|preparing') end - ## - # TODO: shared with 'created' - # until we get one for 'preparing' - # def icon - 'status_created' + 'status_preparing' end - ## - # TODO: shared with 'created' - # until we get one for 'preparing' - # def favicon - 'favicon_status_created' + 'favicon_status_preparing' end end end diff --git a/lib/gitlab/cycle_analytics/base_query.rb b/lib/gitlab/cycle_analytics/base_query.rb index 459bb5177b5..6aedbf64f26 100644 --- a/lib/gitlab/cycle_analytics/base_query.rb +++ b/lib/gitlab/cycle_analytics/base_query.rb @@ -23,6 +23,7 @@ module Gitlab .project(routes_table[:path].as("namespace_path")) query = limit_query(query, project_ids) + query = limit_query_by_date_range(query) # Load merge_requests @@ -34,7 +35,12 @@ module Gitlab def limit_query(query, project_ids) query.where(issue_table[:project_id].in(project_ids)) .where(routes_table[:source_type].eq('Namespace')) - .where(issue_table[:created_at].gteq(options[:from])) + end + + def limit_query_by_date_range(query) + query = query.where(issue_table[:created_at].gteq(options[:from])) + query = query.where(issue_table[:created_at].lteq(options[:to])) if options[:to] + query end def load_merge_requests(query) diff --git a/lib/gitlab/cycle_analytics/issue_helper.rb b/lib/gitlab/cycle_analytics/issue_helper.rb index 295eca5edca..f6f85b84ed8 100644 --- a/lib/gitlab/cycle_analytics/issue_helper.rb +++ b/lib/gitlab/cycle_analytics/issue_helper.rb @@ -12,14 +12,12 @@ module Gitlab .project(routes_table[:path].as("namespace_path")) query = limit_query(query, project_ids) - - query + limit_query_by_date_range(query) end def limit_query(query, project_ids) query.where(issue_table[:project_id].in(project_ids)) .where(routes_table[:source_type].eq('Namespace')) - .where(issue_table[:created_at].gteq(options[:from])) .where(issue_metrics_table[:first_added_to_board_at].not_eq(nil).or(issue_metrics_table[:first_associated_with_milestone_at].not_eq(nil))) end end diff --git a/lib/gitlab/cycle_analytics/plan_helper.rb b/lib/gitlab/cycle_analytics/plan_helper.rb index a63ae58ad21..af4bf6ed3eb 100644 --- a/lib/gitlab/cycle_analytics/plan_helper.rb +++ b/lib/gitlab/cycle_analytics/plan_helper.rb @@ -14,12 +14,11 @@ module Gitlab .where(routes_table[:source_type].eq('Namespace')) query = limit_query(query) - query + limit_query_by_date_range(query) end def limit_query(query) - query.where(issue_table[:created_at].gteq(options[:from])) - .where(issue_metrics_table[:first_added_to_board_at].not_eq(nil).or(issue_metrics_table[:first_associated_with_milestone_at].not_eq(nil))) + query.where(issue_metrics_table[:first_added_to_board_at].not_eq(nil).or(issue_metrics_table[:first_associated_with_milestone_at].not_eq(nil))) .where(issue_metrics_table[:first_mentioned_in_commit_at].not_eq(nil)) end end diff --git a/lib/gitlab/cycle_analytics/stage_summary.rb b/lib/gitlab/cycle_analytics/stage_summary.rb index 5198dd5b4eb..ea440c441b7 100644 --- a/lib/gitlab/cycle_analytics/stage_summary.rb +++ b/lib/gitlab/cycle_analytics/stage_summary.rb @@ -3,16 +3,17 @@ module Gitlab module CycleAnalytics class StageSummary - def initialize(project, from:, current_user:) + def initialize(project, from:, to: nil, current_user:) @project = project @from = from + @to = to @current_user = current_user end def data - [serialize(Summary::Issue.new(project: @project, from: @from, current_user: @current_user)), - serialize(Summary::Commit.new(project: @project, from: @from)), - serialize(Summary::Deploy.new(project: @project, from: @from))] + [serialize(Summary::Issue.new(project: @project, from: @from, to: @to, current_user: @current_user)), + serialize(Summary::Commit.new(project: @project, from: @from, to: @to)), + serialize(Summary::Deploy.new(project: @project, from: @from, to: @to))] end private diff --git a/lib/gitlab/cycle_analytics/summary/base.rb b/lib/gitlab/cycle_analytics/summary/base.rb index 709221c648e..a825d48fb77 100644 --- a/lib/gitlab/cycle_analytics/summary/base.rb +++ b/lib/gitlab/cycle_analytics/summary/base.rb @@ -4,9 +4,10 @@ module Gitlab module CycleAnalytics module Summary class Base - def initialize(project:, from:) + def initialize(project:, from:, to: nil) @project = project @from = from + @to = to end def title diff --git a/lib/gitlab/cycle_analytics/summary/commit.rb b/lib/gitlab/cycle_analytics/summary/commit.rb index f0019b26fa2..76049c6b742 100644 --- a/lib/gitlab/cycle_analytics/summary/commit.rb +++ b/lib/gitlab/cycle_analytics/summary/commit.rb @@ -21,7 +21,7 @@ module Gitlab def count_commits return unless ref - gitaly_commit_client.commit_count(ref, after: @from) + gitaly_commit_client.commit_count(ref, after: @from, before: @to) end def gitaly_commit_client diff --git a/lib/gitlab/cycle_analytics/summary/deploy.rb b/lib/gitlab/cycle_analytics/summary/deploy.rb index 3b56dc2a7bc..0691f3cd131 100644 --- a/lib/gitlab/cycle_analytics/summary/deploy.rb +++ b/lib/gitlab/cycle_analytics/summary/deploy.rb @@ -4,12 +4,18 @@ module Gitlab module CycleAnalytics module Summary class Deploy < Base + include Gitlab::Utils::StrongMemoize + def title n_('Deploy', 'Deploys', value) end def value - @value ||= @project.deployments.where("created_at > ?", @from).count + strong_memoize(:value) do + query = @project.deployments.where("created_at >= ?", @from) + query = query.where("created_at <= ?", @to) if @to + query.count + end end end end diff --git a/lib/gitlab/cycle_analytics/summary/issue.rb b/lib/gitlab/cycle_analytics/summary/issue.rb index 51695c86192..52892eb5a1a 100644 --- a/lib/gitlab/cycle_analytics/summary/issue.rb +++ b/lib/gitlab/cycle_analytics/summary/issue.rb @@ -4,9 +4,10 @@ module Gitlab module CycleAnalytics module Summary class Issue < Base - def initialize(project:, from:, current_user:) + def initialize(project:, from:, to: nil, current_user:) @project = project @from = from + @to = to @current_user = current_user end @@ -15,7 +16,7 @@ module Gitlab end def value - @value ||= IssuesFinder.new(@current_user, project_id: @project.id).execute.created_after(@from).count + @value ||= IssuesFinder.new(@current_user, project_id: @project.id, created_after: @from, created_before: @to).execute.count end end end diff --git a/lib/gitlab/gitaly_client/storage_settings.rb b/lib/gitlab/gitaly_client/storage_settings.rb index 7d1206e551b..43848772947 100644 --- a/lib/gitlab/gitaly_client/storage_settings.rb +++ b/lib/gitlab/gitaly_client/storage_settings.rb @@ -53,7 +53,7 @@ module Gitlab @legacy_disk_path = File.expand_path(storage['path'], Rails.root) if storage['path'] storage['path'] = Deprecated - @hash = storage + @hash = storage.with_indifferent_access end def gitaly_address |