summaryrefslogtreecommitdiff
path: root/app/helpers/admin
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 09:10:19 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 09:10:19 +0000
commit389312d00908adf98b30daac746805ec8447f92b (patch)
tree22409e071143486cd7d72eeefd115ce634f43c84 /app/helpers/admin
parente173c316de15057b099a93053c9ef16180d6d1de (diff)
downloadgitlab-ce-389312d00908adf98b30daac746805ec8447f92b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/helpers/admin')
-rw-r--r--app/helpers/admin/background_migrations_helper.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/helpers/admin/background_migrations_helper.rb b/app/helpers/admin/background_migrations_helper.rb
new file mode 100644
index 00000000000..698d81cc8a2
--- /dev/null
+++ b/app/helpers/admin/background_migrations_helper.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Admin
+ module BackgroundMigrationsHelper
+ def batched_migration_status_badge_class_name(migration)
+ class_names = {
+ 'active' => 'badge-info',
+ 'paused' => 'badge-warning',
+ 'failed' => 'badge-danger',
+ 'finished' => 'badge-success'
+ }
+
+ class_names[migration.status]
+ end
+
+ # The extra logic here is needed because total_tuple_count is just
+ # an estimate and completed_rows also does not account for last jobs
+ # whose batch size is likely larger than the actual number of rows processed
+ def batched_migration_progress(migration, completed_rows)
+ return 100 if migration.finished?
+ return 0 unless completed_rows.to_i > 0
+ return unless migration.total_tuple_count.to_i > 0
+
+ [100 * completed_rows / migration.total_tuple_count, 99].min
+ end
+ end
+end