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

Fixed number of entries #92

Open
AllanGH opened this issue Nov 2, 2021 · 0 comments
Open

Fixed number of entries #92

AllanGH opened this issue Nov 2, 2021 · 0 comments

Comments

@AllanGH
Copy link

AllanGH commented Nov 2, 2021

get_household_timeline will always return number of entries as a multiple of 25 as page_size=max_entries_per_page.

E.g. setting entries=1 returns 25 entries, where setting entries=26 returns 50 entries.

surepy/surepy/__init__.py

Lines 245 to 264 in 5d72298

async def get_household_timeline(
self, household_id: int | None = None, entries: int = 25
) -> list[dict[str, Any]]:
"""Fetch Felaqua water level information."""
# pagination as the api gives us at most 25 results per page
max_entries_per_page = 25
pages_to_fetch = ceil(entries / max_entries_per_page)
current_page = 1
household_timeline = []
while current_page <= pages_to_fetch:
resource = HOUSEHOLD_TIMELINE_RESOURCE.format(
BASE_RESOURCE=BASE_RESOURCE,
household_id=household_id,
page=current_page,
page_size=max_entries_per_page,
)

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

No branches or pull requests

1 participant