debian-mirror-gitlab/app/helpers/admin/background_migrations_helper.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
830 B
Ruby
Raw Normal View History

2021-09-04 01:27:46 +05:30
# frozen_string_literal: true
module Admin
module BackgroundMigrationsHelper
2022-03-02 08:16:31 +05:30
def batched_migration_status_badge_variant(migration)
variants = {
2022-06-21 17:19:12 +05:30
active: :info,
paused: :warning,
failed: :danger,
finished: :success
2021-09-04 01:27:46 +05:30
}
2022-06-21 17:19:12 +05:30
variants[migration.status_name]
2021-09-04 01:27:46 +05:30
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