Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions osf/management/commands/reindex_versioned_preprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

def reindex_versioned_preprints(dry_run=False, batch_size=100, provider_id=None, guids=None):
if guids:
preprints = Preprint.objects.filter(guids___id__in=guids)
preprints = Preprint.objects.filter(versioned_guids__guid___id__in=guids)
else:
preprints = Preprint.objects.filter(versioned_guids__isnull=False).distinct()
preprints = Preprint.objects.filter(versioned_guids__isnull=False)

if provider_id:
preprints = preprints.filter(provider___id=provider_id)
Expand Down Expand Up @@ -38,12 +38,6 @@ def reindex_versioned_preprints(dry_run=False, batch_size=100, provider_id=None,
else:
try:
preprint.update_search()
if processed % 10 == 0:
logger.info(
f'Re-indexed preprint {preprint._id} '
f'(version {preprint.versioned_guids.first().version if preprint.versioned_guids.exists() else "N/A"}) '
f'[{processed}/{total_count}]'
)
except Exception as e:
logger.error(f'Failed to re-index preprint {preprint._id}: {e}')

Expand Down Expand Up @@ -100,5 +94,5 @@ def handle(self, *args, **options):
dry_run=dry_run,
batch_size=batch_size,
provider_id=provider_id,
guids=guids
guids=[guids]
)
2 changes: 2 additions & 0 deletions osf/metadata/osf_gathering.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ def gather_flexible_types(focus):
def gather_created(focus):
if focus.rdftype == OSF.Registration:
yield (DCTERMS.created, getattr(focus.dbmodel, 'registered_date', None))
elif focus.rdftype == OSF.Preprint:
yield (DCTERMS.created, focus.dbmodel.date_created_first_version)
else:
yield (DCTERMS.created, getattr(focus.dbmodel, 'created', None))

Expand Down
Loading