diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-06 15:07:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-06 15:07:34 +0300 |
commit | 4958d96e262f6b31b2850123e4949536555b2d29 (patch) | |
tree | 28fe9a1fed009a569806c705e4810a33979cbd6a /db | |
parent | 95de7177f2d5844e4aa399fea9a59d4ba6b4b1f1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db')
-rw-r--r-- | db/fixtures/development/17_cycle_analytics.rb | 22 | ||||
-rw-r--r-- | db/migrate/20230605043814_add_trigram_index_for_vulnerability_reads_container_images.rb | 19 | ||||
-rw-r--r-- | db/schema_migrations/20230605043814 | 1 | ||||
-rw-r--r-- | db/structure.sql | 2 |
4 files changed, 42 insertions, 2 deletions
diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb index 0175647e71e..6f4819c5ca4 100644 --- a/db/fixtures/development/17_cycle_analytics.rb +++ b/db/fixtures/development/17_cycle_analytics.rb @@ -3,8 +3,8 @@ require './spec/support/sidekiq_middleware' require './spec/support/helpers/test_env' require 'active_support/testing/time_helpers' -require './spec/support/helpers/cycle_analytics_helpers.rb' -require './ee/db/seeds/shared/dora_metrics.rb' if Gitlab.ee? +require './spec/support/helpers/cycle_analytics_helpers' +require './ee/db/seeds/shared/dora_metrics' if Gitlab.ee? # Usage: # @@ -82,6 +82,7 @@ class Gitlab::Seeder::CycleAnalytics # rubocop:disable Style/ClassAndModuleChild seed_staging_stage! if Gitlab.ee? + create_vulnerabilities_count_report! seed_dora_metrics! create_custom_value_stream! create_value_stream_aggregation(project.group) @@ -195,6 +196,23 @@ class Gitlab::Seeder::CycleAnalytics # rubocop:disable Style/ClassAndModuleChild end end + def create_vulnerabilities_count_report! + 4.times do |i| + critical_count = rand(5..10) + high_count = rand(5..10) + + [i.months.ago.end_of_month, i.months.ago.beginning_of_month].each do |date| + FactoryBot.create(:vulnerability_historical_statistic, + date: date, + total: critical_count + high_count, + critical: critical_count, + high: high_count, + project: project + ) + end + end + end + def create_developers! 5.times do |i| user = FactoryBot.create( diff --git a/db/migrate/20230605043814_add_trigram_index_for_vulnerability_reads_container_images.rb b/db/migrate/20230605043814_add_trigram_index_for_vulnerability_reads_container_images.rb new file mode 100644 index 00000000000..f614f16dff2 --- /dev/null +++ b/db/migrate/20230605043814_add_trigram_index_for_vulnerability_reads_container_images.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class AddTrigramIndexForVulnerabilityReadsContainerImages < Gitlab::Database::Migration[2.1] + disable_ddl_transaction! + + INDEX_NAME = 'index_vulnerability_reads_on_location_image_trigram' + REPORT_TYPES = { container_scanning: 2, cluster_image_scanning: 7 }.freeze + + def up + add_concurrent_index :vulnerability_reads, :location_image, + name: INDEX_NAME, + using: :gin, opclass: { location_image: :gin_trgm_ops }, + where: "report_type = ANY (ARRAY[#{REPORT_TYPES.values.join(', ')}]) AND location_image IS NOT NULL" + end + + def down + remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME + end +end diff --git a/db/schema_migrations/20230605043814 b/db/schema_migrations/20230605043814 new file mode 100644 index 00000000000..067917a1bd2 --- /dev/null +++ b/db/schema_migrations/20230605043814 @@ -0,0 +1 @@ +f03ee1653d68dee14261380f8dd270d849133c33403eceb310999bc22cbe4084
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 194c752cb91..2c12ac39a8a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -33034,6 +33034,8 @@ CREATE INDEX index_vulnerability_reads_on_location_image ON vulnerability_reads CREATE INDEX index_vulnerability_reads_on_location_image_partial ON vulnerability_reads USING btree (project_id, location_image) WHERE ((report_type = ANY (ARRAY[2, 7])) AND (location_image IS NOT NULL)); +CREATE INDEX index_vulnerability_reads_on_location_image_trigram ON vulnerability_reads USING gin (location_image gin_trgm_ops) WHERE ((report_type = ANY (ARRAY[2, 7])) AND (location_image IS NOT NULL)); + CREATE INDEX index_vulnerability_reads_on_namespace_type_severity_id ON vulnerability_reads USING btree (namespace_id, report_type, severity, vulnerability_id); CREATE INDEX index_vulnerability_reads_on_scanner_id ON vulnerability_reads USING btree (scanner_id); |