diff --git a/osf/management/commands/recatalog_metadata.py b/osf/management/commands/recatalog_metadata.py index d46face0ba69..be52e9b0a0e6 100644 --- a/osf/management/commands/recatalog_metadata.py +++ b/osf/management/commands/recatalog_metadata.py @@ -55,21 +55,6 @@ def _recatalog_all(queryset, chunk_size): recatalog(queryset, start_id=0, chunk_count=int(9e9), chunk_size=chunk_size) -def _recatalog_datacite_custom_types(chunk_size): - logger.info('recataloguing items with datacite custom type...') - # all preprints - _recatalog_all(Preprint.objects, chunk_size) - # objects with custom resource_type_general - for _model in {Registration, Node, OsfStorageFile}: - _queryset = ( - _model.objects - .exclude(guids__metadata_record__isnull=True) - .exclude(guids__metadata_record__resource_type_general='') - ) - _recatalog_all(_queryset, chunk_size) - logger.info('done recataloguing items with datacite custom type!') - - class Command(BaseCommand): def add_arguments(self, parser): type_group = parser.add_mutually_exclusive_group(required=True) @@ -103,14 +88,6 @@ def add_arguments(self, parser): action='store_true', help='recatalog metadata for users', ) - type_group.add_argument( - '--datacite-custom-types', - action='store_true', - help='''recatalog metadata for items with a specific datacite type, - including all preprints and items with custom resource_type_general - (may be slow for lack of database indexes) - ''', - ) provider_group = parser.add_mutually_exclusive_group() provider_group.add_argument( @@ -161,15 +138,8 @@ def handle(self, *args, **options): start_id = options['start_id'] chunk_size = options['chunk_size'] chunk_count = options['chunk_count'] - datacite_custom_types = options['datacite_custom_types'] also_decatalog = options['also_decatalog'] - if datacite_custom_types: # temporary arg for datacite 4.5 migration - assert not start_id, 'oh no, cannot resume with `--datacite-custom-types`' - assert not provider_ids, 'oh no, cannot filter providers with `--datacite-custom-types`' - _recatalog_datacite_custom_types(chunk_size) - return # end - if pls_all_types: assert not start_id, 'choose a specific type to resume with --start-id' provided_models = [Preprint, Registration, Node, OSFUser, OsfStorageFile] diff --git a/osf_tests/management_commands/test_recatalog_metadata.py b/osf_tests/management_commands/test_recatalog_metadata.py index 4354a54048ef..550f06e4d136 100644 --- a/osf_tests/management_commands/test_recatalog_metadata.py +++ b/osf_tests/management_commands/test_recatalog_metadata.py @@ -2,11 +2,9 @@ import pytest from unittest import mock from operator import attrgetter -import random from django.core.management import call_command -from osf.models.metadata import GuidMetadataRecord from osf_tests.factories import ( PreprintProviderFactory, PreprintFactory, @@ -77,21 +75,6 @@ def users(self, preprints, registrations, projects): for preprint in preprints ]))) - @pytest.fixture - def items_with_custom_datacite_type(self, preprints, registrations, projects, files): - _nonpreprint_sample = [ - random.choice(_items) - for _items in (registrations, projects, files) - ] - for _item in _nonpreprint_sample: - _guid_record = GuidMetadataRecord.objects.for_guid(_item) - _guid_record.resource_type_general = 'BookChapter' # datacite resourceTypeGeneral value - _guid_record.save() - return { - *preprints, # every preprint has datacite type "Preprint" - *_nonpreprint_sample, - } - @pytest.fixture def decatalog_items(self, registrations): _user = UserFactory(allow_indexing=False) @@ -119,7 +102,6 @@ def test_recatalog_metadata( projects, files, users, - items_with_custom_datacite_type, decatalog_items, ): def _actual_osfids() -> set[str]: @@ -206,16 +188,6 @@ def _actual_osfids() -> set[str]: mock_update_share_task.reset_mock() - # datacite custom types - call_command( - 'recatalog_metadata', - '--datacite-custom-types', - ) - _expected_osfids = set(_iter_osfids(items_with_custom_datacite_type)) - assert _expected_osfids == _actual_osfids() - - mock_update_share_task.reset_mock() - # all types _all_public_items = [*preprints, *registrations, *projects, *files, *users] call_command(