summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2019-07-07 10:50:04 +0700
committerShinya Maeda <shinya@gitlab.com>2019-07-07 11:18:07 +0700
commit4d8c2c743b875772f92722b902cd76c67c7f5597 (patch)
treede3be6a3aeeab006239e8afb31a22c5e65c7999b
parentbd69c9197cefcb31ebabe466df005f1451ac1c46 (diff)
downloadgitlab-ce-show-pipeline-progress.tar.gz
Show pipeline progressshow-pipeline-progress
We calculate pipeline progress from the count of alive builds.
-rw-r--r--app/assets/images/ci_favicons/favicon_status_running_100.pngbin0 -> 1228 bytes
-rw-r--r--app/assets/images/ci_favicons/favicon_status_running_25.pngbin0 -> 1192 bytes
-rw-r--r--app/assets/images/ci_favicons/favicon_status_running_50.pngbin0 -> 1237 bytes
-rw-r--r--app/assets/images/ci_favicons/favicon_status_running_75.pngbin0 -> 1208 bytes
-rw-r--r--app/models/ci/build.rb8
-rw-r--r--app/models/ci/pipeline.rb4
-rw-r--r--app/models/ci/stage.rb4
-rw-r--r--lib/gitlab/ci/status/running.rb16
8 files changed, 31 insertions, 1 deletions
diff --git a/app/assets/images/ci_favicons/favicon_status_running_100.png b/app/assets/images/ci_favicons/favicon_status_running_100.png
new file mode 100644
index 00000000000..fb8a1cb263d
--- /dev/null
+++ b/app/assets/images/ci_favicons/favicon_status_running_100.png
Binary files differ
diff --git a/app/assets/images/ci_favicons/favicon_status_running_25.png b/app/assets/images/ci_favicons/favicon_status_running_25.png
new file mode 100644
index 00000000000..e918a17e601
--- /dev/null
+++ b/app/assets/images/ci_favicons/favicon_status_running_25.png
Binary files differ
diff --git a/app/assets/images/ci_favicons/favicon_status_running_50.png b/app/assets/images/ci_favicons/favicon_status_running_50.png
new file mode 100644
index 00000000000..141cf2dda6b
--- /dev/null
+++ b/app/assets/images/ci_favicons/favicon_status_running_50.png
Binary files differ
diff --git a/app/assets/images/ci_favicons/favicon_status_running_75.png b/app/assets/images/ci_favicons/favicon_status_running_75.png
new file mode 100644
index 00000000000..a3f3af34cf9
--- /dev/null
+++ b/app/assets/images/ci_favicons/favicon_status_running_75.png
Binary files differ
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 89cc082d0bc..ff790004cfe 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -786,6 +786,14 @@ module Ci
:creating
end
+ def self.alive_ratio
+ sql = <<~SQL
+ SELECT (#{alive.select('COUNT(*)').to_sql})::float / (#{select('COUNT(*)').to_sql});
+ SQL
+
+ ActiveRecord::Base.connection.execute(sql).first.values.first
+ end
+
private
def successful_deployment_status
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 20ca4a9ab24..95b891ed58e 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -794,6 +794,10 @@ module Ci
errors ? errors.full_messages.to_sentence : ""
end
+ def progress
+ (1.0 - builds.alive_ratio) * 100.0
+ end
+
private
def ci_yaml_from_repo
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb
index d90339d90dc..f2f6dec8de3 100644
--- a/app/models/ci/stage.rb
+++ b/app/models/ci/stage.rb
@@ -124,5 +124,9 @@ module Ci
def manual_playable?
blocked? || skipped?
end
+
+ def progress
+ (1.0 - builds.alive_ratio) * 100.0
+ end
end
end
diff --git a/lib/gitlab/ci/status/running.rb b/lib/gitlab/ci/status/running.rb
index ac7dd74cdce..014ffc81396 100644
--- a/lib/gitlab/ci/status/running.rb
+++ b/lib/gitlab/ci/status/running.rb
@@ -17,7 +17,21 @@ module Gitlab
end
def favicon
- 'favicon_status_running'
+ if subject.respond_to?(:progress)
+ progress = subject.progress
+
+ if progress < 25.0
+ 'favicon_status_running_25'
+ elsif progress < 50.0
+ 'favicon_status_running_50'
+ elsif progress < 75.0
+ 'favicon_status_running_75'
+ elsif progress < 100.0
+ 'favicon_status_running_100'
+ end
+ else
+ 'favicon_status_running'
+ end
end
end
end