Skip to content

Conversation

mshabarov
Copy link
Contributor

@mshabarov mshabarov commented Oct 8, 2021

Description

Limits the number of requested items from backend to a given threshold of ten pages.

Depends on vaadin/web-components#2801 and web-components new release.

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

Additional for Feature type of change

  • Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

Limits the number of requested items from backend to a given threshold of ten pages.
@@ -65,6 +65,7 @@
public static final int DEFAULT_PAGE_INCREASE_COUNT = 4;

private static final int DEFAULT_PAGE_SIZE = 50;
private static final int MAXIMUM_ALLOWED_ITEMS_FACTOR = 10;
Copy link

Choose a reason for hiding this comment

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

Factor ? I would simply call it pages e.g. maximum allowed pages since it seems to correspond to that, so why not just name it for that ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, it's better no name it maximum allowed pages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -317,6 +318,14 @@ public DataCommunicator(DataGenerator<T> dataGenerator,
* the end of the requested range
*/
public void setRequestedRange(int start, int length) {
final int maximumAllowedItems = getMaximumAllowedItems();
if (length > maximumAllowedItems) {
throw new IllegalStateException(String.format(
Copy link

Choose a reason for hiding this comment

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

Why throwing and breaking the UI ? What happens if the length is limited to maximum allowed ?

IIRC, the grid will simply request again if it needs more (?).
And the server side will anyway keep fetching for more until less are returned than what was requested, or until the size has been reached.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right. Better to cut/limit the requested items, than to throw. So I'll just warn about too many items requested and cut the length to acceptable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that was a wrong decision. Otherwise we would likely have seen bug much much earlier.

@vaadin-bot
Copy link
Collaborator

SonarQube analysis reported 3 issues

  1. MAJOR DataCommunicator.java#L325: Invoke method(s) only conditionally. rule
  2. MAJOR DataCommunicator.java#L1086: Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed. rule
  3. INFO DataCommunicator.java#L495: Complete the task associated to this TODO comment. rule

@mshabarov mshabarov requested a review from pleku October 27, 2021 10:14
@mshabarov mshabarov marked this pull request as ready for review November 1, 2021 12:10
@pleku pleku merged commit 0ec90bf into master Nov 1, 2021
@pleku pleku deleted the fix/fetch-items-limit branch November 1, 2021 12:11
vaadin-bot pushed a commit that referenced this pull request Nov 1, 2021
Limits the number of requested items from backend to a given threshold of ten pages.
@vaadin-bot
Copy link
Collaborator

Hi @mshabarov and @pleku, when i performed cherry-pick to this commit to 2.7, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 0ec90bf
error: could not apply 0ec90bf... fix: Limit the requested pages to a given threshold (#12003)
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add ' or 'git rm '
hint: and commit the result with 'git commit'

@vaadin-bot
Copy link
Collaborator

Hi @mshabarov and @pleku, when i performed cherry-pick to this commit to 1.0, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick 0ec90bf
error: could not apply 0ec90bf... fix: Limit the requested pages to a given threshold (#12003)
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add ' or 'git rm '
hint: and commit the result with 'git commit'

vaadin-bot added a commit that referenced this pull request Nov 1, 2021
Limits the number of requested items from backend to a given threshold of ten pages.

Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
mshabarov added a commit that referenced this pull request Nov 2, 2021
Limits the number of requested items from backend to a given threshold of ten pages.

(cherry picked from commit 0ec90bf)
mshabarov added a commit that referenced this pull request Nov 2, 2021
Limits the number of requested items from backend to a given threshold of ten pages.

(cherry picked from commit 0ec90bf)
pleku pushed a commit that referenced this pull request Nov 4, 2021
…#12238)

Limits the number of requested items from backend to a given threshold of ten pages.

(cherry picked from commit 0ec90bf)
mshabarov added a commit that referenced this pull request Nov 4, 2021
…#12238)

Limits the number of requested items from backend to a given threshold of ten pages.

(cherry picked from commit 0ec90bf)
pleku pushed a commit that referenced this pull request Nov 4, 2021
…#12238) (#12275)

Limits the number of requested items from backend to a given threshold of ten pages.

(cherry picked from commit 0ec90bf)
mcollovati added a commit that referenced this pull request Jan 9, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403
mshabarov pushed a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403
vaadin-bot pushed a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403
vaadin-bot pushed a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403
vaadin-bot pushed a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403
vaadin-bot pushed a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403
vaadin-bot pushed a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403
mcollovati added a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403
vaadin-bot added a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403

Co-authored-by: Marco Collovati <marco@vaadin.com>
vaadin-bot added a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403

Co-authored-by: Marco Collovati <marco@vaadin.com>
vaadin-bot added a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403

Co-authored-by: Marco Collovati <marco@vaadin.com>
vaadin-bot added a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403

Co-authored-by: Marco Collovati <marco@vaadin.com>
mcollovati added a commit that referenced this pull request Jan 10, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403

Co-authored-by: Marco Collovati <marco@vaadin.com>
mcollovati added a commit that referenced this pull request Jan 11, 2024
Limits the number of requested items from backend to a given threshold of ten pages.
Exactly the same as #12003, but applied to HierarchicalDataCommunicator.

Fixes #18403
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants