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

Add CbpStrategy accepting OBP params #517

Merged
merged 4 commits into from
Nov 8, 2023
Merged

Add CbpStrategy accepting OBP params #517

merged 4 commits into from
Nov 8, 2023

Conversation

ecoologic
Copy link
Collaborator

@ecoologic ecoologic commented Nov 2, 2023

if you use the iterator with a CBP resource, you might not need to update the sort and pagination parameters.

This starts the upgrade guide, but please don't consider it complete or final. More work will come in that area.

I suggest reviewers to use Split view.

@ecoologic ecoologic changed the title Add CbpStrategy orderParams() Add CbpStrategy accepting OBP params Nov 3, 2023
$params['sort_order']
);
return $params;
}
Copy link
Collaborator Author

@ecoologic ecoologic Nov 3, 2023

Choose a reason for hiding this comment

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

so now the CbpStrategy knows a lot about OBP. I thought of extracting it, and I did,
but it leads to a lot of indirection. In the end I prefer to accept some duplication and imperfect encapsulation in favour of simpler code.

@@ -0,0 +1,67 @@
# Upgrade guide
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's a little duplication in the info below, but I think it's worth giving a TLDR summary.

@ecoologic ecoologic requested a review from a team November 3, 2023 05:33
@ecoologic ecoologic marked this pull request as ready for review November 3, 2023 05:33
foreach ($ticketsIterator as $ticket) {
process($ticket); // Your implementation
foreach ($iterator as $ticket) {
echo($ticket->id . " ");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I now prefer code that is fully testable, without having to define process

@ecoologic ecoologic force-pushed the RED-1984-order branch 2 times, most recently from 22ee2fa to 3976fad Compare November 3, 2023 05:54
UPGRADE_GUIDE.md Show resolved Hide resolved
UPGRADE_GUIDE.md Outdated

**OBP (Offset Based Pagination)** is quite inefficient, and increasingly so the higher the page you fetch. Switching to **CBP (Cursor Based Pagination)** will improve your application performance. OBP will eventually be subject to limits.

When in OBP you request page 100, the DB will need to index all 100 pages of records before it can load the rows for the page you requested.

Choose a reason for hiding this comment

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

Should we rephrase this? Maybe something like:

When using OBP, if you request page 100, the DB will need to index all records that proceed it before it can load the rows for the page you requested.

UPGRADE_GUIDE.md Outdated
}
```

If this is your situation, **you need to change sorting order** to a supported one.

Choose a reason for hiding this comment

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

Possibly change this to:

If this is your situation, you will need to change the sorting order to a supported one.

UPGRADE_GUIDE.md Outdated

## The new iterator

Your best solution to implement CBP is to use the newly provided iterator on your resources, for example:

Choose a reason for hiding this comment

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

Nitpickiest nitpick. I

The most elegant way to implement CBP....

Copy link

@Zendesk-NathanBellette Zendesk-NathanBellette left a comment

Choose a reason for hiding this comment

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

NIce work! Approved.

@ecoologic ecoologic merged commit 1665ebf into master Nov 8, 2023
2 checks passed
@ecoologic ecoologic deleted the RED-1984-order branch November 8, 2023 22:36
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