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: Add pagination to position history endpoint #401

Merged
merged 4 commits into from
Dec 19, 2024

Conversation

KeneePatel
Copy link
Contributor

Changes include:

  • Constant of PAGINATION_STEP is added with the value of 10
  • get_user_positions function endpoint now has an optional start argument for accepting query parameter of start
  • get_positions_by_wallet_id db function now accepts start, and limit parameters to accommodate the change

No breaking changes

Modification to a functionality is done and was to be expected due to the nature of issue.

@KeneePatel
Copy link
Contributor Author

Ahh the good old failing tests. Will have to refactor them for the modified changes. I will take some time for those.

@KeneePatel
Copy link
Contributor Author

Some guidance on how I should approach for the tests to pass will be appreciated. I am still a bit ambiguous on how I should tackle the test cases.

I can try to modify the functions so they integrate well the existing test cases, or refactor the test cases to accommodate the functional changes? Please tell me which route would be a better option.

@djeck1432 djeck1432 self-requested a review December 18, 2024 10:49
@djeck1432 djeck1432 linked an issue Dec 18, 2024 that may be closed by this pull request
Copy link
Owner

@djeck1432 djeck1432 left a comment

Choose a reason for hiding this comment

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

Regarding test cases, you can adjust them based on your changes


positions = position_db_connector.get_positions_by_wallet_id(wallet_id)

if start is not None:
Copy link
Owner

Choose a reason for hiding this comment

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

   if start is not None:
   start_index = max(0, start)
    else:
        start_index = 0

this all code can be done in one line:
start_index = start and max(0, start) or 0

@djeck1432
Copy link
Owner

@KeneePatel Any updates,
please also fix test cases

@djeck1432
Copy link
Owner

@KeneePatel Any updates? Just friendly reminder that if you don't update PR you can be unassigned

@KeneePatel
Copy link
Contributor Author

It was busy today. I will update the PR in 6 hours.

@djeck1432
Copy link
Owner

@KeneePatel okay, thank you for update

@KeneePatel KeneePatel requested a review from djeck1432 December 19, 2024 07:02
Copy link
Owner

@djeck1432 djeck1432 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@djeck1432 djeck1432 merged commit 5055348 into djeck1432:main Dec 19, 2024
4 checks 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.

[Backend] Add pagination to position history endpoint
2 participants