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

refactor: New util to fetch same url multiple times to avoid exceeding the max length with one query parameter #265

Merged

Conversation

kevinszuchet
Copy link
Contributor

Closes #263

Copy link
Contributor

@LautaroPetaccio LautaroPetaccio left a comment

Choose a reason for hiding this comment

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

Great abstraction 👍 I've left some comments to review.

src/ports/utils.ts Outdated Show resolved Hide resolved
return (data as PaginatedResponse<T>).results !== undefined
}

export async function queryMultipleTimesWhenExceedingUrlLimit<T>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind adding tests for this new auxiliary function?

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!

Comment on lines 91 to 92
const param =
(alreadyHasQueryParams ? `&` : '') + `${queryParameterName}=${value}`
Copy link
Contributor

Choose a reason for hiding this comment

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

This should, if it's the first element of the array, choose between using ? or & depending on if it already has query parameters or not, and then, for all of the other cases, append &.
As it is here, if the base url doesn't have query parameters, it will concatenate all of the query parameters without the use of &.

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!

kevinszuchet and others added 3 commits April 10, 2023 12:17
Co-authored-by: Lautaro Petaccio <1120791+LautaroPetaccio@users.noreply.github.com>
Signed-off-by: Kevin Szuchet <31735779+kevinszuchet@users.noreply.github.com>
Copy link
Contributor

@LautaroPetaccio LautaroPetaccio left a comment

Choose a reason for hiding this comment

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

Looks great 🚀

@kevinszuchet kevinszuchet merged commit bd7332b into master Apr 10, 2023
@kevinszuchet kevinszuchet deleted the refactor/fn-to-query-multiple-urls-when-exceding-limit branch April 10, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants