Display only top-level assets per default - #2523
Open
Ahmad-Wahid wants to merge 4 commits into
Open
Conversation
Context: - Issue #2518 wants the asset listings to show only top-level assets per default, which the UI does by passing depth=0. - num-records was counted from the account/type filter alone, so a listing scoped to a subtree reported every other asset as filtered out by the search. Change: - Apply filter_assets_under_root to the num-records count as well, whenever root or depth is given. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Context: - Issue #2518: an organisation's asset list is hard to scan when every sub-asset is listed alongside the sites they belong to, and you cannot narrow it down without knowing what to search for. Change: - Add a "Top-level only" checkbox, checked per default, to the asset listing on the account page and on /assets. - When checked, the listing requests depth=0, so the API returns only assets without a parent asset. - On the account page, the checkbox sits left of the one for public assets, as the issue asks. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Context: - Issue #2518 adds a "Top-level only" default to the asset listings, backed by the API's depth parameter. Change: - Assert that depth=0 drops the descendants from GET /assets, and that the same listing would include them without it. - Assert that num-records then counts the top-level assets only, so nothing reads as filtered out by the search. - Assert that both asset listings render the checkbox checked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Context: - Issue #2518, PR #2523. Change: - Main changelog, under New features: the asset lists now default to top-level assets. - API change log, as v3.0-36: num-records now respects the root/depth subtree constraint. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Documentation build overview
|
Ahmad-Wahid
marked this pull request as ready for review
September 11, 2026 10:01
nhoening
requested changes
Sep 11, 2026
nhoening
left a comment
Member
There was a problem hiding this comment.
Works nicely!
I only have two small wishes:
- Keep the two checkboxes next to each other, so we use less vertical space
- Please add the checkbox for public asset also to the general assets view (asset.html), so the two are more alike. (also off per default)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
/assets. When checked, the listing asks the API fordepth=0, so only assets without a parent asset are returned; unchecking it restores the full listing.GET /api/v3_0/assetsnow applies theroot/depthsubtree constraint tonum-recordsas well, not just to the paginated query. Without this, a listing scoped to a subtree reports every asset outside it as filtered from N total entries in the table footer.documentation/changelog.rst(plus av3.0-36entry indocumentation/api/change_log.rst)No new API parameter was needed: the existing
depthparameter already means "how many generations of descendants to include", anddepth=0(without aroot) selects exactly the assets that have no parent asset.Look & Feel
How to test
flexmeasures/api/v3_0/tests/test_assets_api.py::test_get_assets_top_level_only—depth=0drops the descendants, and the same listing without it includes them (so the assertion is not vacuous).flexmeasures/api/v3_0/tests/test_assets_api.py::test_get_assets_top_level_only_record_counts—num-recordsthen counts the top-level assets only.flexmeasures/ui/tests/test_asset_crud.py::test_assets_page_defaults_to_top_level_assetsandflexmeasures/ui/tests/test_account_crud.py::test_account_page_defaults_to_top_level_assets— both listings render the checkbox checked.To prove the new tests can fail: passing
max_depth=Noneintofilter_assets_under_rootin the index endpoint turns both API tests red; reverting only thenum-recordspart turns just the record-counts test red; dropping thecheckedattribute from the two templates turns both UI tests red.Test runs:
flexmeasures/uipasses in full (133 passed).flexmeasures/apipasses (461 passed) withtest_jobs_api.py,test_asset_jobs_api_fresh_db.py,test_asset_schedules_fresh_db.py,test_sensor_schedules*.pyexcluded — those segfault inside HiGHS on this machine, onmainas well as on this branch, so it is a local environment problem rather than a regression. CI covers them.Further Improvements
assetsTableTitleon the account page is referenced by the public-assets handler but no element with that id exists, so that title update is dead code today. Left alone here.Related Items
Closes #2518
Sign-off
🤖 Generated with Claude Code