Skip to content
Snippets Groups Projects
Unverified Commit 41c7998d authored by Ravi Kumar's avatar Ravi Kumar Committed by GitLab
Browse files

Merge branch 'mark_obsolete-20240208160152--add-count-fields-to-projects' into 'master'

parents 98406aae 0a3226a6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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'
Loading
Loading
@@ -18,3 +18,5 @@ def new_mappings
}
end
end
AddCountFieldsToProjects.prepend ::Elastic::MigrationObsolete
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment