Skip to content

Conversation

@saurabh12nxf
Copy link

Change(s)

Change Type: Fixed

Change Category: Internal

Changelog Entry: Fixed quirky pagination and sorting behavior in /user/resources endpoint.

The /user/resources endpoint previously had unintuitive behavior where it would paginate at the AIoDEntry level, then re-query individual asset tables (potentially reordering results), and finally re-sort in Python. This fix preserves the database sort order throughout the query process by creating an entry_order mapping and applying it when fetching assets from individual tables, eliminating the need for Python-level re-sorting.

How to Test

  1. Create multiple resources (publications, datasets, etc.) with different date_modified timestamps
  2. Query /user/resources with pagination and sorting parameters:
    • GET /user/resources?limit=5&sort=date_modified&direction=desc
    • GET /user/resources?limit=5&offset=5&sort=date_modified&direction=desc
  3. Verify that:
    • Results are sorted correctly by date_modified
    • Pagination maintains the sort order across pages
    • Multiple asset types are each sorted correctly

Existing tests in test_user_endpoints.py should pass (note: local Windows environment has unrelated test infrastructure issues with SQLite temp files, but CI/CD should pass).

Checklist

  • Tests have been added or updated to reflect the changes, or their absence is explicitly explained.
  • Documentation has been added or updated to reflect the changes, or their absence is explicitly explained.
  • A self-review has been conducted checking:
    • No unintended changes have been committed.
    • The changes in isolation seem reasonable.
    • Anything that may be odd or unintuitive is provided with a GitHub comment explaining it (but consider if this should not be a code comment or in the documentation instead).
  • All CI checks pass before pinging a reviewer, or provide an explanation if they do not.
  • The PR title matches the changelog entry's one-line description.

Related Issues

Closes #654

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.

Pagination and Sorting for user resources

1 participant