diff --git a/ee/elastic/docs/20240208160152_add_count_fields_to_projects.yml b/ee/elastic/docs/20240208160152_add_count_fields_to_projects.yml index 3c224d5b6cd1605f5eb03ec21a664110fb0274bb..1d0eb890026056acdc00bcd68cf3598ee0072f94 100644 --- a/ee/elastic/docs/20240208160152_add_count_fields_to_projects.yml +++ b/ee/elastic/docs/20240208160152_add_count_fields_to_projects.yml @@ -5,6 +5,6 @@ description: Add star_count and last_repository_updated_date to projects index. group: group::global search milestone: '16.10' introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/144557 -obsolete: false -marked_obsolete_by_url: -marked_obsolete_in_milestone: +obsolete: true +marked_obsolete_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/169309 +marked_obsolete_in_milestone: '17.6' diff --git a/ee/elastic/migrate/20240208160152_add_count_fields_to_projects.rb b/ee/elastic/migrate/20240208160152_add_count_fields_to_projects.rb index 87aaf685335782839eaf7bd5cb80001a5e0e2305..7d247ac4b22b6d8a1b4126e07379a06bf01d7d30 100644 --- a/ee/elastic/migrate/20240208160152_add_count_fields_to_projects.rb +++ b/ee/elastic/migrate/20240208160152_add_count_fields_to_projects.rb @@ -18,3 +18,5 @@ def new_mappings } end end + +AddCountFieldsToProjects.prepend ::Elastic::MigrationObsolete diff --git a/ee/lib/elastic/latest/project_instance_proxy.rb b/ee/lib/elastic/latest/project_instance_proxy.rb index af3cf2c077964f0eec00d3a346a9e9d4a2cc3c80..5b13ebfc2fe9f785cf6e166949b8706a5cbb7c3b 100644 --- a/ee/lib/elastic/latest/project_instance_proxy.rb +++ b/ee/lib/elastic/latest/project_instance_proxy.rb @@ -32,7 +32,8 @@ def as_indexed_json(_options = {}) :visibility_level, :last_activity_at, :name_with_namespace, - :path_with_namespace + :path_with_namespace, + :star_count ].each do |attr| data[attr.to_s] = safely_read_attribute_for_elasticsearch(attr) end @@ -48,6 +49,8 @@ def as_indexed_json(_options = {}) data['ci_catalog'] = target.catalog_resource.present? + data['last_repository_updated_date'] = target.last_repository_updated_at + if ::Elastic::DataMigrationService.migration_has_finished?(:add_fields_to_projects_index) data['mirror'] = target.mirror? data['forked'] = target.forked? || false @@ -55,8 +58,6 @@ def as_indexed_json(_options = {}) data['repository_languages'] = target.repository_languages.map(&:name) end - data.merge!(add_count_fields(target)) - data end @@ -64,18 +65,6 @@ def as_indexed_json(_options = {}) def es_parent "n_#{target.root_ancestor.id}" end - - private - - def add_count_fields(target) - data = {} - if ::Elastic::DataMigrationService.migration_has_finished?(:add_count_fields_to_projects) - data['star_count'] = target.star_count - data['last_repository_updated_date'] = target.last_repository_updated_at - end - - data - end end end end diff --git a/ee/spec/elastic/migrate/20240208160152_add_count_fields_to_projects_spec.rb b/ee/spec/elastic/migrate/20240208160152_add_count_fields_to_projects_spec.rb index ad388c946df990a8667140159b4b8085c1af4973..c2c0db85e6ca086ed25973a767637ddda525afdf 100644 --- a/ee/spec/elastic/migrate/20240208160152_add_count_fields_to_projects_spec.rb +++ b/ee/spec/elastic/migrate/20240208160152_add_count_fields_to_projects_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' require File.expand_path('ee/elastic/migrate/20240208160152_add_count_fields_to_projects.rb') -RSpec.describe AddCountFieldsToProjects, :elastic, feature_category: :global_search do - let(:version) { 20240208160152 } - - include_examples 'migration adds mapping' +RSpec.describe AddCountFieldsToProjects, feature_category: :global_search do + it_behaves_like 'a deprecated Advanced Search migration', 20240208160152 end diff --git a/ee/spec/lib/elastic/latest/project_instance_proxy_spec.rb b/ee/spec/lib/elastic/latest/project_instance_proxy_spec.rb index 7aefd8436ed4ad167dd78799c379bce206e73b51..19efe7f8923d9618bd63409bceab41796938cd52 100644 --- a/ee/spec/lib/elastic/latest/project_instance_proxy_spec.rb +++ b/ee/spec/lib/elastic/latest/project_instance_proxy_spec.rb @@ -72,19 +72,6 @@ expect(result.keys).not_to include(:repository_languages) end end - - context 'when add_count_fields_to_projects migration is not completed' do - before do - set_elasticsearch_migration_to(:add_count_fields_to_projects, including: false) - end - - it 'does not include the gated fields' do - result = proxy.as_indexed_json.with_indifferent_access - - expect(result.keys).not_to include(:star_count) - expect(result.keys).not_to include(:last_repository_updated_date) - end - end end describe '#es_parent' do diff --git a/ee/spec/models/concerns/elastic/project_spec.rb b/ee/spec/models/concerns/elastic/project_spec.rb index 83aba46c1f94d37d68a2de6c0c544a14ce113e29..b0cc61869cd6df35d68ca27f04d7c82499b42596 100644 --- a/ee/spec/models/concerns/elastic/project_spec.rb +++ b/ee/spec/models/concerns/elastic/project_spec.rb @@ -211,19 +211,6 @@ expect(project.__elasticsearch__.as_indexed_json).to eq(expected_hash) end - context 'when add_count_fields_to_projects is not finished' do - before do - set_elasticsearch_migration_to(:add_count_fields_to_projects, including: false) - end - - it 'does not include the ci_catalog field' do - as_indexed_json = project.__elasticsearch__.as_indexed_json - - expect(as_indexed_json).not_to have_key('star_count') - expect(as_indexed_json).not_to have_key('last_repository_updated_date') - end - end - context 'when add_fields_to_projects_index is not finished' do before do set_elasticsearch_migration_to(:add_fields_to_projects_index, including: false)