Skip to content

Commit 4c6b3b0

Browse files
committed
Update share
1 parent b602108 commit 4c6b3b0

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

osf/management/commands/reindex_versioned_preprints.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
def reindex_versioned_preprints(dry_run=False, batch_size=100, provider_id=None, guids=None):
1010
if guids:
11-
preprints = Preprint.objects.filter(guids___id__in=guids)
11+
preprints = Preprint.objects.filter(versioned_guids__guid___id__in=guids)
1212
else:
13-
preprints = Preprint.objects.filter(versioned_guids__isnull=False).distinct()
13+
preprints = Preprint.objects.filter(versioned_guids__isnull=False)
1414

1515
if provider_id:
1616
preprints = preprints.filter(provider___id=provider_id)
@@ -38,12 +38,6 @@ def reindex_versioned_preprints(dry_run=False, batch_size=100, provider_id=None,
3838
else:
3939
try:
4040
preprint.update_search()
41-
if processed % 10 == 0:
42-
logger.info(
43-
f'Re-indexed preprint {preprint._id} '
44-
f'(version {preprint.versioned_guids.first().version if preprint.versioned_guids.exists() else "N/A"}) '
45-
f'[{processed}/{total_count}]'
46-
)
4741
except Exception as e:
4842
logger.error(f'Failed to re-index preprint {preprint._id}: {e}')
4943

@@ -100,5 +94,5 @@ def handle(self, *args, **options):
10094
dry_run=dry_run,
10195
batch_size=batch_size,
10296
provider_id=provider_id,
103-
guids=guids
97+
guids=[guids]
10498
)

osf/metadata/osf_gathering.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ def gather_flexible_types(focus):
419419
def gather_created(focus):
420420
if focus.rdftype == OSF.Registration:
421421
yield (DCTERMS.created, getattr(focus.dbmodel, 'registered_date', None))
422+
elif focus.rdftype == OSF.Preprint:
423+
yield (DCTERMS.created, focus.dbmodel.date_created_first_version)
422424
else:
423425
yield (DCTERMS.created, getattr(focus.dbmodel, 'created', None))
424426

0 commit comments

Comments
 (0)