Skip to content

Conversation

@Vlad0n20
Copy link
Contributor

Purpose

Update Created field in search card

Changes

Add new propery for Preprint model date_created_first_version. As it propery reindex via admin page doesn't have efect, because date_created_first_version doesn't fit for save_fieds. So I add manage command to reindex all existing preprints properly.

QA Notes

Please make verification statements inspired by your code and what your code touches.

  • Verify
  • Verify

What are the areas of risk?

Any concerns/considerations/questions that development raised?

Documentation

Side Effects

Ticket

https://openscience.atlassian.net/browse/ENG-9122?atlOrigin=eyJpIjoiMWFlODI2MzVjZDI5NDkyY2I2M2FhYzc3NDdhZGM0NmEiLCJwIjoiaiJ9

@adlius adlius requested a review from cslzchen November 12, 2025 21:23
Copy link
Collaborator

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall and left a few questions for me to understand the issue and the fix better.

Comment on lines -804 to +808
first_version = base_guid.versions.filter(is_rejected=False).order_by('version').first()
first_version = base_guid.versions.order_by('version').first()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what's the reason behind this change? Does it have to do with the corner case where all versions are rejected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the filter(is_rejected=False) ensures:

  • We always get the actual first version chronologically (version 1)
  • The code handles the "all versions rejected" case correctly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see date_created_first_version is a new property in the target pb&s feature branch. And thus this first_version here only affects this new property.

logger = logging.getLogger(__name__)


def reindex_versioned_preprints(dry_run=False, batch_size=100, provider_id=None, guids=None):
Copy link
Collaborator

@cslzchen cslzchen Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a "backfill" command that fix existing preprints' indexing. Do we have to run this daily (or more frequently) to re-index? If understand this correctly, we should/must also fix the indexing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, new preprints and versions are indexed appropriately.

Copy link
Collaborator

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the explanation. Make sure @adlius and/CE is aware of the command that needs to be run in each server.

Comment on lines -804 to +808
first_version = base_guid.versions.filter(is_rejected=False).order_by('version').first()
first_version = base_guid.versions.order_by('version').first()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see date_created_first_version is a new property in the target pb&s feature branch. And thus this first_version here only affects this new property.

@adlius adlius merged commit ef49be6 into CenterForOpenScience:feature/pbs-25-21 Nov 20, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants