Skip to content

Add order fields#561

Merged
jdcourcol merged 4 commits intomainfrom
add_order_fields
Mar 19, 2026
Merged

Add order fields#561
jdcourcol merged 4 commits intomainfrom
add_order_fields

Conversation

@jdcourcol
Copy link
Contributor

@jdcourcol jdcourcol commented Mar 18, 2026

The GUI is limited by the fact that many fields are not sortable with entity core REST API.
This is adding many fields for ordering.

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
pytest 97.93% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
app/filters/cell_morphology.py 100.00% <ø> (ø)
app/filters/circuit.py 100.00% <100.00%> (ø)
app/filters/em_cell_mesh.py 100.00% <ø> (ø)
app/filters/emodel.py 100.00% <ø> (ø)
app/filters/ion_channel.py 100.00% <ø> (ø)
app/filters/ion_channel_model.py 100.00% <100.00%> (ø)
app/filters/simulation.py 100.00% <100.00%> (ø)
app/filters/simulation_campaign.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@GianlucaFicarelli GianlucaFicarelli left a comment

Choose a reason for hiding this comment

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

LGTM, my only concern is for performance:


  1. when ordering by an attribute in a nested model, the select query needs to join or left join with additional tables, and sort on that attribute to be able to select the desired page of results. If there are many records and there isn't a good index to use, the query might be not very efficient.

Example of queries:

  • without nested ordering: SELECT entity.type ... ORDER BY entity.creation_date DESC, cell_morphology.id
  • with nested ordering: SELECT entity.type ... LEFT OUTER JOIN (entity AS entity_3 JOIN subject AS subject_2 ON entity_3.id = subject_2.id) ON scientific_artifact.subject_id = subject_2.id ... ORDER BY subject_2.name ASC, cell_morphology.id

  1. the additional joins are added also to the query that counts the records, although it's not needed. This is because the ordering attributes are handled together with the filtering attributes to determine the join to apply here.

Example of queries:

  • without nested ordering: SELECT count(distinct(cell_morphology.id)) ...
  • with nested ordering: SELECT count(distinct(cell_morphology.id)) ... LEFT OUTER JOIN (entity AS entity_1 JOIN subject AS subject_1 ON entity_1.id = subject_1.id) ON scientific_artifact.subject_id = subject_1.id

We can check in staging if these queries are taking longer, and decide if it's worth to fix the count query by ignoring in that case the joins that are needed only for ordering and not for filtering.

@jdcourcol
Copy link
Contributor Author

Thank you for the feedback, that is what I was worried about.

@jdcourcol jdcourcol merged commit 836ed1f into main Mar 19, 2026
2 checks passed
@jdcourcol jdcourcol deleted the add_order_fields branch March 19, 2026 13:04
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.

2 participants