Conversation
WalkthroughThis pull request updates the package version, modifies a property assignment within the subgraph mapper, adds a logging statement in the positions module, refines several GraphQL queries by removing an unused field and adding filters, and updates test cases for open and closed positions. These changes adjust how data is sourced and validated while extending test coverage. Changes
Sequence Diagram(s)sequenceDiagram
participant T as Test Suite
participant OP as OpenPositions Function
participant Q as Query Module
participant S as Subgraph
T->>OP: getAllOpenPositionsWithTime(startTime, endTime)
OP->>Q: Build query with openPositionCount_gt: 0
Q->>S: Execute query
S-->>Q: Return subgraphResponse
Q-->>OP: Return subgraphResponse
OP->>Console: Log subgraphResponse
OP-->>T: Return open positions
sequenceDiagram
participant T as Test Suite
participant CP as ClosedPositions Function
participant Q as Query Module
participant S as Subgraph
T->>CP: getAllPositionHistoryWithTime(startTime, endTime)
CP->>Q: Build query with totalPositionsCount_gt: 0
Q->>S: Execute query
S-->>Q: Return subgraphResponse
Q-->>CP: Return subgraphResponse
CP-->>T: Return closed positions
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/subgraph/positions/index.ts (1)
207-207: Consider removing the console.log statement.This logging statement appears to be added for debugging purposes. While useful during development, console logs should generally be removed from production code as they can clutter logs and potentially impact performance.
- console.log('subgraphresponse', subgraphResponse);Alternatively, consider using a proper logging framework with configurable log levels if this information is needed for troubleshooting in production environments.
test/subgraph-tests/position.test.ts (1)
44-44: Remove or comment out console.log statements.Console log statements in tests can clutter test output. Consider removing them or commenting them out before merging to production.
- console.log('Position data:::', positionData); + // console.log('Position data:::', positionData);Also applies to: 52-52
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
package.json(1 hunks)src/common/subgraphMapper.ts(1 hunks)src/subgraph/positions/index.ts(1 hunks)src/subgraph/positions/subgraphQueries.ts(2 hunks)test/subgraph-tests/position.test.ts(1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
test/subgraph-tests/position.test.ts (1)
test/index.ts (1)
getParifiSdkInstanceForTesting(5-33)
🪛 Biome (1.9.4)
test/subgraph-tests/position.test.ts
[error] 47-47: Don't focus the test.
The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.
(lint/suspicious/noFocusedTests)
🪛 GitHub Actions: Test contracts sdk
test/subgraph-tests/position.test.ts
[error] 34-34: Error fetching positions: ClientError: GraphQL Error (Code: 403): Access denied.
🔇 Additional comments (7)
package.json (1)
3-3: Version bump looks appropriate.The increment from 2.2.11 to 2.2.12 follows semantic versioning principles, indicating a patch release with backward-compatible bug fixes. This aligns with the changes being made across the other files.
src/common/subgraphMapper.ts (1)
45-45: Good fix for the owner property mapping.The change from accessing
wallettoownercorrectly aligns with the GraphQL schema structure seen in the queries. This fixes a potential bug where the owner information wasn't being properly mapped from the response data.Verify that this change has been validated in your tests to ensure the property is correctly accessed in all scenarios.
src/subgraph/positions/subgraphQueries.ts (2)
404-407: Good performance improvement for open positions query.Adding the
openPositionCount_gt:0filter to the query is an excellent optimization. This will filter out accounts with no open positions at the database level rather than fetching unnecessary data, resulting in:
- Reduced network payload
- Faster query execution
- Less client-side processing
472-472: Good optimization for position history query.Adding the
totalPositionsCount_gt :0filter ensures we only fetch accounts that have at least one position in their history. This optimization will:
- Improve query performance
- Reduce unnecessary data transfer
- Speed up response times
test/subgraph-tests/position.test.ts (3)
41-42: Verify the timeframe values are correct.The timeframe values (Unix timestamps) deserve validation:
- Open positions: startTime=1735689600 (Jan 1, 2025), endTime=2035689600 (Jan 27, 2034)
- Closed positions: startTime=1743710952 (May 1, 2025), endTime=1743763152 (May 2, 2025)
These timestamps are in the future. Please confirm they're intentional for testing purposes.
Also applies to: 49-50
39-46: LGTM - Test for open positions.The test for retrieving open positions within a specific timeframe looks good. It properly tests the
getAllOpenPositionsWithTimemethod with appropriate expectations.
31-38: LGTM - Removing.onlyfrom existing test.Good change to remove the
.onlymodifier from this test, allowing all tests to run.🧰 Tools
🪛 GitHub Actions: Test contracts sdk
[error] 34-34: Error fetching positions: ClientError: GraphQL Error (Code: 403): Access denied.
Summary by CodeRabbit