Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorted versions didn't place latest version at the top #2955

Open
fenekku opened this issue Jan 13, 2025 · 2 comments
Open

Sorted versions didn't place latest version at the top #2955

fenekku opened this issue Jan 13, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@fenekku
Copy link
Contributor

fenekku commented Jan 13, 2025

Package version (if known): v12

Describe the bug

We encountered cases where version sorting was incorrect: the top version spot should correspond to the most recent version, but it does not:

image

The banner says so correctly and the json data of the record as well: {"versions": {"is_latest": false, "index": 2}.

Parts that seem weird to me are that 10.18131/qsmj5-thn10 (wrongly sorted record) has

  • same version title as correctly sorted record: "Version 2" and
  • same versions index as correctly sorted record: {"versions": {"is_latest": true, "index": 2}

We are reaching out to depositor to know what they did, but I am fairly sure that the index should have been different and that this is a system problem. I don't know if this is systematic or if the user managed to fall in an edge case.

Expected behavior

See entry with "is_latest": true have the latest index (different than other) and be at the top of the sorting.

Screenshots (if applicable)

Additional context

2 more instances of this problem showed up (by same depositor). Here is a screenshot of another one:

image

And this incorrect sorting isn't always the case:

image

so what is going on?

@fenekku fenekku added the bug Something isn't working label Jan 13, 2025
@tmorrell
Copy link
Contributor

The order is based on the index number, and if you somehow end up with two versions with the same index you'll get weird behavior like you've seen. You can fix it as an admin with this script https://github.com/caltechlibrary/caltechauthors/blob/main/scripts/change_version_index.py

I haven't seen duplicate version indexes from user behavior. The index gets incremented here https://github.com/inveniosoftware/invenio-drafts-resources/blob/4a89ac19ffd046e8675aa22ebdbdebb8ff6e6518/invenio_drafts_resources/records/systemfields/versions.py#L100, but if this never gets called I guess you could end up with multiple versions with the same index.

We have a need to reorder versions, and I was playing around with adding some of that functionality into drafts_resources caltechlibrary/invenio-drafts-resources@66ed8ef, but figured it might be too controversial. If you end up needing to do more version management let me know, since we'll probably want to tackle it at some point.

@fenekku
Copy link
Contributor Author

fenekku commented Jan 13, 2025

Thanks for confirming that @tmorrell . In any case I do wonder why the parent index wasn't incremented - probably an edge case bug since I can't reproduce right now. We'll reach out to the depositor and see if they can give us more context.

We don't have a need for version re-ordering right now, but it seems like an index switch should indeed do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants