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

feat: [sc-207225] [SAP-OData] Implement server side pagination #13

Merged
merged 12 commits into from
Jan 29, 2025

Conversation

alexbourret
Copy link
Collaborator

@@ -21,10 +21,11 @@ def __init__(self, config, plugin_config):
object 'plugin_config' to the constructor
"""
Connector.__init__(self, config, plugin_config)
logger.info("Starting SAP-OData v1.0.3")
logger.info("Starting SAP-OData v1.0.4-beta.3")

Choose a reason for hiding this comment

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

Still in beta?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed in c798cc8

Comment on lines +101 to +109
if self.is_client_side_pagination():
if self.bulk_size == 0:
return None
bulk_size = self.bulk_size
if records_limit > 0:
bulk_size = records_limit if records_limit < bulk_size else bulk_size
else:
bulk_size = None
return bulk_size

Choose a reason for hiding this comment

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

Optional:

Suggested change
if self.is_client_side_pagination():
if self.bulk_size == 0:
return None
bulk_size = self.bulk_size
if records_limit > 0:
bulk_size = records_limit if records_limit < bulk_size else bulk_size
else:
bulk_size = None
return bulk_size
if not self.is_client_side_pagination() or self.bulk_size <= 0:
return None
# Unlimited records_limit. Default to bulk_size
if records_limit < 0:
return self.bulk_size
return min(self.bulk_size, records_limit)

Comment on lines +87 to +88
if skip is None:
skip = 0

Choose a reason for hiding this comment

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

:question Why not initialize skip to 0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if skip==0, the ?skip=0 query string is sent to the request, which is something we want to avoid if no client side pagination is being used.


class RecordsLimit():
def __init__(self, records_limit=-1):
self.has_no_limit = (records_limit == -1)

Choose a reason for hiding this comment

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

Since this property is only used in is_reached, I think it's better to isolate it in the same condition in case the property is modified and has_no_limit is not updated

self.records_limit = records_limit
self.counter = 0

def is_reached(self):

Choose a reason for hiding this comment

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

Naming is kinda confusing, I did not expect it to increment the counter. Imo you can call separate the increment into another method

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed in c798cc8

@alexbourret alexbourret merged commit ece3a86 into master Jan 29, 2025
1 check passed
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