diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-14 00:09:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-14 00:09:54 +0300 |
commit | 0fea036ba7c8d26ffeecc7f52bf770ea3a88689e (patch) | |
tree | 5937f3181e46bdc2c96ba9b530bc66d0ef46311f /db/click_house | |
parent | 46e1fdb8bbdaf149371334f1a1757ba4d68fe020 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/click_house')
-rw-r--r-- | db/click_house/migrate/main/20231207173100_create_ci_used_minutes.rb | 26 | ||||
-rw-r--r-- | db/click_house/migrate/main/20231207173101_create_ci_used_minutes_mv.rb | 27 |
2 files changed, 53 insertions, 0 deletions
diff --git a/db/click_house/migrate/main/20231207173100_create_ci_used_minutes.rb b/db/click_house/migrate/main/20231207173100_create_ci_used_minutes.rb new file mode 100644 index 00000000000..901b0eed756 --- /dev/null +++ b/db/click_house/migrate/main/20231207173100_create_ci_used_minutes.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class CreateCiUsedMinutes < ClickHouse::Migration + def up + execute <<~SQL + CREATE TABLE IF NOT EXISTS ci_used_minutes + ( + project_id UInt64 DEFAULT 0, + status LowCardinality(String) DEFAULT '', + runner_type UInt8 DEFAULT 0, + finished_at_bucket DateTime64(6, 'UTC') DEFAULT now64(), + + count_builds AggregateFunction(count), + total_duration SimpleAggregateFunction(sum, Int64) + ) + ENGINE = AggregatingMergeTree() + ORDER BY (finished_at_bucket, project_id, status, runner_type) + SQL + end + + def down + execute <<~SQL + DROP TABLE ci_used_minutes + SQL + end +end diff --git a/db/click_house/migrate/main/20231207173101_create_ci_used_minutes_mv.rb b/db/click_house/migrate/main/20231207173101_create_ci_used_minutes_mv.rb new file mode 100644 index 00000000000..856710b660e --- /dev/null +++ b/db/click_house/migrate/main/20231207173101_create_ci_used_minutes_mv.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class CreateCiUsedMinutesMv < ClickHouse::Migration + def up + execute <<~SQL + CREATE MATERIALIZED VIEW IF NOT EXISTS ci_used_minutes_mv + TO ci_used_minutes + AS + SELECT + project_id, + status, + runner_type, + toStartOfInterval(finished_at, INTERVAL 1 day) AS finished_at_bucket, + + countState() AS count_builds, + sumSimpleState(duration) AS total_duration + FROM ci_finished_builds + GROUP BY project_id, status, runner_type, finished_at_bucket + SQL + end + + def down + execute <<~SQL + DROP VIEW ci_used_minutes_mv + SQL + end +end |