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

[Graph] Paginate through index patterns #120972

Merged
merged 9 commits into from
Dec 16, 2021

Conversation

majagrubic
Copy link
Contributor

@majagrubic majagrubic commented Dec 9, 2021

Summary

Addresses: #93770

While in the original issue refers to pagination on the server side, we were tagged in that issue, although Graph was making a large request for index patterns on the client side. Since saved object client already supports pagination, this PR breaks one big request into paginated smaller requests.

Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials

  • Unit or functional tests were updated or added to match the most common scenarios
    - [ ] Any UI touched in this PR is usable by keyboard only (learn more about keyboard accessibility)
    - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: FF, Chrome)
    - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
    - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this in your browser)
    - [ ] This was checked for cross-browser compatibility

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

@majagrubic majagrubic added v8.1.0 release_note:fix Feature:Graph Graph application feature Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) labels Dec 13, 2021
@majagrubic majagrubic marked this pull request as ready for review December 13, 2021 15:30
@majagrubic majagrubic requested a review from a team as a code owner December 13, 2021 15:30
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-graph (Feature:Graph)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@dimaanj dimaanj left a comment

Choose a reason for hiding this comment

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

LGTM, looks stylish.

.then((response) => {
perPage = response.perPage;
total = response.total;
page = response.page;
Copy link
Member

Choose a reason for hiding this comment

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

so this function is starting let with page = 1, which is requesting the first page, then you assign the value page = response.page; which is I think also the first page, since it was requested. It seems to me that in the case when there is a bigger total number than 1000, it would trigger makeRequest forever, since page is not incremented?

Co-authored-by: Matthias Wilhelm <ankertal@gmail.com>
Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Tested a-la-carte in Chrome, by setting perPage to 1, works as expected 👍

Comment on lines +91 to +92
perPage = response.perPage;
total = response.total;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: shouldn't be necessary to set perPage since it shouldn't change, which means it could be a const

@kertal
Copy link
Member

kertal commented Dec 16, 2021

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
graph 444.5KB 444.7KB +190.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@majagrubic majagrubic merged commit 8c9f847 into elastic:main Dec 16, 2021
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Dec 16, 2021
@majagrubic majagrubic deleted the graph-load-indexpatterns branch December 16, 2021 13:39
TinLe pushed a commit to TinLe/kibana that referenced this pull request Dec 22, 2021
* [Graph] Paginate through index patterns

* Extract logic into a generator function

* Fix failing unit test

* Fix page initialization

* Update x-pack/plugins/graph/public/helpers/use_workspace_loader.ts

Co-authored-by: Matthias Wilhelm <ankertal@gmail.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Matthias Wilhelm <ankertal@gmail.com>
gbamparop pushed a commit to gbamparop/kibana that referenced this pull request Jan 12, 2022
* [Graph] Paginate through index patterns

* Extract logic into a generator function

* Fix failing unit test

* Fix page initialization

* Update x-pack/plugins/graph/public/helpers/use_workspace_loader.ts

Co-authored-by: Matthias Wilhelm <ankertal@gmail.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Matthias Wilhelm <ankertal@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Graph Graph application feature release_note:fix Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants