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

Add parameters for sorting options (GSI-329) #15

Merged
merged 14 commits into from
Sep 6, 2023

Conversation

TheByronHimes
Copy link
Member

@TheByronHimes TheByronHimes commented Sep 1, 2023

Main change: Adds a way to control how the results are sorted, via the sorting_parameters parameter (a list of objects, each with "field" and "order")
e.g.

{
  "class_name": "Dataset",
  "query": "",
  "filters": [],
  "skip": 0,
  "limit": 0,
  "sorting_parameters": [
    {
      "field": "title",
      "order": "descending"
    },
    {
      "field": "id_",
      "order": "ascending"
    }
  ]
}

Some notes:

  • Duplicate field names will result in a validation error from pydantic. This is because the parameters for the sort operation in mongo are a single dictionary.
  • If id_ is not passed in explicitly, it will be added as the final sort key by the QueryHandler, and always in ascending order.
  • The facets section of the aggregation pipeline now runs unconditionally, and the sorting takes place therein right after the renaming of the ID field. Previously there was a condition to only run the function when there were facetable properties supplied. The config conditions mean that, in practice, it will always run.

@github-actions
Copy link

github-actions bot commented Sep 4, 2023

Pull Request Test Coverage Report for Build 6074312337

  • 28 of 28 (100.0%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 90.766%

Totals Coverage Status
Change from base Build 6037320504: 0.5%
Covered Lines: 403
Relevant Lines: 444

💛 - Coveralls

@TheByronHimes TheByronHimes merged commit 1598193 into main Sep 6, 2023
6 checks passed
@TheByronHimes TheByronHimes deleted the feature/sorting_options_GSI-329 branch September 6, 2023 12:48
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