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

Restore prior API ordering when page param is not specified #1560

Merged
merged 3 commits into from
May 21, 2024

Conversation

dydxwill
Copy link
Contributor

@dydxwill dydxwill commented May 21, 2024

Changelist

Restore prior API ordering when page param is not specified

Test Plan

Unit tested.

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • Bug Fixes
    • Improved ordering of fills and trades when fetching with market filters and pagination parameters.

Copy link
Contributor

coderabbitai bot commented May 21, 2024

Walkthrough

The recent updates primarily focus on ensuring the correct ordering of fills and trades in the indexer service. Specifically, the changes involve modifying test cases and controller logic to conditionally apply ordering based on the presence of pagination parameters. This ensures that the data retrieval is both efficient and correctly ordered, enhancing the reliability and accuracy of the service.

Changes

Files Change Summary
indexer/services/comlink/__tests__/controllers/api/v4/fills-controller.test.ts Modified test cases to ensure correct ordering of fills, added pagination parameters, and updated expectations.
indexer/services/comlink/src/controllers/api/v4/fills-controller.ts Conditionalized the orderBy parameter based on the presence of the page variable.
indexer/services/comlink/src/controllers/api/v4/trades-controller.ts Applied similar conditional logic for the orderBy parameter based on the page variable.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 1c36b0b and 52a43d0.
Files selected for processing (3)
  • indexer/services/comlink/tests/controllers/api/v4/fills-controller.test.ts (3 hunks)
  • indexer/services/comlink/src/controllers/api/v4/fills-controller.ts (2 hunks)
  • indexer/services/comlink/src/controllers/api/v4/trades-controller.ts (1 hunks)
Additional Context Used
Path-based Instructions (3)
indexer/services/comlink/src/controllers/api/v4/trades-controller.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/comlink/src/controllers/api/v4/fills-controller.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

indexer/services/comlink/__tests__/controllers/api/v4/fills-controller.test.ts (1)

Pattern **/**: Do not include a walkthrough. For all comments on line changes that are longer than 15 lines, add a prefix to the comment of what lines you are commenting on (for example: "The changes from lines 100 to 200...". Add your comment to be on the last 15 lines of the chunk rather than adding your comment to the entire chunk.

Additional comments not posted (4)
indexer/services/comlink/src/controllers/api/v4/trades-controller.ts (1)

76-76: Conditional ordering based on the page parameter looks correct and aligns with the PR objectives.

indexer/services/comlink/src/controllers/api/v4/fills-controller.ts (2)

171-171: Conditional ordering based on the page parameter in getFillsForParentSubaccount method is implemented correctly.

Verification successful

The getFillsForParentSubaccount method is only used within the same file where it is defined. The conditional ordering based on the page parameter is implemented correctly and does not affect other functionalities.

  • indexer/services/comlink/src/controllers/api/v4/fills-controller.ts: The method getFillsForParentSubaccount is used within this file.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the conditional ordering in `getFillsForParentSubaccount` does not affect other functionalities.

# Test: Search for other usages of the `getFillsForParentSubaccount` method. Expect: No adverse effects on other functionalities.
rg --type typescript $'getFillsForParentSubaccount'

Length of output: 85



Script:

#!/bin/bash
# Description: Verify that the conditional ordering in `getFillsForParentSubaccount` does not affect other functionalities.

# Test: Search for other usages of the `getFillsForParentSubaccount` method. Expect: No adverse effects on other functionalities.
rg --type ts $'getFillsForParentSubaccount'

Length of output: 298


96-96: Conditional ordering based on the page parameter in getFills method is implemented correctly.

Verification successful

The conditional ordering based on the page parameter in the getFills method is implemented correctly and does not adversely affect other functionalities.

  • The getFills method is used within the same file and is called in a controlled context.
  • The context of the calls to getFills and getFillsForParentSubaccount shows no adverse effects from the conditional ordering.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the conditional ordering in `getFills` does not affect other functionalities.

# Test: Search for other usages of the `getFills` method. Expect: No adverse effects on other functionalities.
rg --type typescript $'getFills'

Length of output: 66



Script:

#!/bin/bash
# Description: Verify that the conditional ordering in `getFills` does not affect other functionalities.

# Test: Search for other usages of the `getFills` method. Expect: No adverse effects on other functionalities.
rg --type ts $'getFills'

Length of output: 497



Script:

#!/bin/bash
# Extract lines around the calls to `getFills` to understand the context.
rg --type ts -A 5 -B 5 $'controller.getFills' indexer/services/comlink/src/controllers/api/v4/fills-controller.ts

Length of output: 846

indexer/services/comlink/__tests__/controllers/api/v4/fills-controller.test.ts (1)

Line range hint 128-213: Updated test case for ordering fills correctly reflects the changes in pagination and ordering logic.

Verification successful

The search results indicate that there are multiple test cases related to orders across various files. However, it is not clear if these tests specifically cover the new ordering logic introduced in the fills-controller.

To ensure comprehensive test coverage for the new ordering logic, it would be prudent to manually verify the relevant test cases or generate additional scripts to further investigate the specific tests related to ordering fills.


The search results indicate that there are multiple test cases related to ordering fills, particularly in the fills-controller.test.ts file. This suggests that the new ordering logic is likely covered by these tests.

  • indexer/services/comlink/__tests__/controllers/api/v4/fills-controller.test.ts: Contains several test cases related to ordering fills, including:
    • it('Get /fills with market gets correctly ordered fills', async () => {
    • it('Get /fills with market gets fills ordered by createdAtHeight descending and paginated', async () => {

These test cases should adequately cover the new ordering logic introduced in the fills-controller.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the test coverage for the new ordering logic is adequate.

# Test: Search for other tests related to ordering. Expect: Comprehensive test coverage.
rg --type typescript $'it.*orders'

Length of output: 70



Script:

#!/bin/bash
# Description: Verify that the test coverage for the new ordering logic is adequate.

# Test: Search for other tests related to ordering. Expect: Comprehensive test coverage.
rg --glob '*.ts' $'it.*orders'

Length of output: 12359



Script:

#!/bin/bash
# Description: Verify that the test coverage for the new ordering logic in fills is adequate.

# Test: Search for test cases related to ordering fills. Expect: Comprehensive test coverage.
rg --glob '*.ts' 'it.*fills'

Length of output: 3903

@dydxwill dydxwill merged commit 5ed80b6 into main May 21, 2024
11 checks passed
@dydxwill dydxwill deleted the wl/restore_order branch May 21, 2024 18:43
@dydxwill
Copy link
Contributor Author

https://github.com/Mergifyio backport release/indexer/v5.x

Copy link
Contributor

mergify bot commented May 21, 2024

backport release/indexer/v5.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request May 21, 2024
dydxwill added a commit that referenced this pull request May 21, 2024
…1560) (#1561)

Co-authored-by: dydxwill <119354122+dydxwill@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants