-
Notifications
You must be signed in to change notification settings - Fork 36
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
feat: pagination on accounts listing #1196
Conversation
Signed-off-by: joshuaunity <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can delete some code in the UI code which gathers accounts for the page. Only then the loading of the page will actually improve.
True, ill remove that. |
Signed-off-by: joshuaunity <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I see in the roles column something like this: "[object Object], [object Object]"
- Let's not show the logo column. Many will not have one, so it's empty space, and we also do not show colors here anyways.
Signed-off-by: joshuaunity <[email protected]>
…account page load speed Signed-off-by: joshuaunity <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, please add a changelog entry, then we can merge!
Signed-off-by: joshuaunity <[email protected]>
Ok, adding that... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
Just a few notes for a follow-up PR to clean up tiny docs mistakes and also a potential bug.
|
||
- If the `page` parameter is not provided, all assets are returned, without pagination information. The result will be a list of assets. | ||
- If a `page` parameter is provided, the response will be paginated, showing a specific number of assets per page as defined by `per_page` (default is 10). | ||
- If a search 'filter' such as 'solar "ACME corp"' is provided, the response will filter out assets where each search term is either present in their name or account name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment needs an update. We are not actually applying the search filter to asset names.
The endpoint supports pagination of the asset list using the `page` and `per_page` query parameters. | ||
|
||
- If the `page` parameter is not provided, all assets are returned, without pagination information. The result will be a list of assets. | ||
- If a `page` parameter is provided, the response will be paginated, showing a specific number of assets per page as defined by `per_page` (default is 10). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should speak of accounts rather than assets.
"num-records" : 1, | ||
"filtered-records" : 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant spaces.
'primary_color': '#1a3443' | ||
'secondary_color': '#f1a122' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing commas.
) | ||
|
||
if filter: | ||
search_terms = filter[0].split(" ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way of splitting does not work with search terms in quotes, such as the "ACME corp" in the docstring example.
Actually, since the SearchFilterField
is used, the search string should already be split into a list of search terms, where each term may contain spaces. This line likely results in only applying the first search time, which is why it may have escaped developer testing.
@nhoening this is an example of why I suggested refactoring. The pagination implementation for assets uses a better function for splitting, which I had moved to a schema so any pagination implementation using search terms would use the same.
@@ -12,6 +12,7 @@ New features | |||
* The data chart on the asset page splits up its color-coded sensor legend when showing more than 7 sensors, becoming a legend per subplot [see `PR #1176 <https://github.com/FlexMeasures/flexmeasures/pull/1176>`_ and `PR #1193 <https://github.com/FlexMeasures/flexmeasures/pull/1193>`_ | |||
* Speed up loading the users page, by making the pagination backend-based and adding support for that in the API [see `PR #1160 <https://github.com/FlexMeasures/flexmeasures/pull/1160>`] | |||
* X-axis labels in CLI plots show datetime values in a readable and informative format [see `PR #1172 <https://github.com/FlexMeasures/flexmeasures/pull/1172>`_] | |||
* Speed up loading the accounts page,by making the pagination backend-based and adding support for that in the API [see `PR #1196 <https://github.com/FlexMeasures/flexmeasures/pull/1196>`_] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after comma.
from flexmeasures.data.services.accounts import get_accounts, get_audit_log_records | ||
from flexmeasures.api.common.schemas.users import AccountIdField | ||
from flexmeasures.data.schemas.account import AccountSchema | ||
from flexmeasures.api.common.schemas.generic_assets import SearchFilterField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This schema should move to a more generic module, as it doesn't only deal with assets.
Description
This PR adds pagination to the accounts API and accounts page on the frontend
Look & Feel
How to test
Steps to test it or name of the tests functions.
Visit the accounts page.
Further Improvements
None
Related Items
This PR closes #1155