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

Mithril listed incorrectly in squence in market (third rarest resource) #2112

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

aymericdelab
Copy link
Collaborator

@aymericdelab aymericdelab commented Nov 15, 2024

Fixes #2064

Summary by CodeRabbit

  • New Features

    • Enhanced resource management in the trading panel with improved clarity and robustness.
    • Streamlined filtering and mapping logic for resources using resource IDs.
  • Bug Fixes

    • Improved error handling to prevent application crashes when resources are not found.
  • Refactor

    • Updated component props to consistently use resourceId for better maintainability and readability.
    • Adjusted calculations and logic to directly utilize resource IDs from RESOURCE_TIERS.

Copy link

vercel bot commented Nov 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eternum ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 3:43pm
eternum-docs ❌ Failed (Inspect) Nov 15, 2024 3:43pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
eternum-landing ⬜️ Ignored (Inspect) Visit Preview Nov 15, 2024 3:43pm

Copy link
Contributor

mentatbot bot commented Nov 15, 2024

You are out of MentatBot reviews. Your usage will refresh November 18 at 08:00 AM.

Copy link
Contributor

coderabbitai bot commented Nov 15, 2024

Walkthrough

The pull request introduces modifications across three components: LiquidityTable, MarketOrderPanel, and MarketResourceSidebar. The changes primarily focus on improving code clarity and robustness in handling resource identifiers. The LiquidityTable component's filtering logic is reformatted for better readability. The MarketOrderPanel and MarketResourceSidebar components update their handling of resource identifiers, replacing resource with resourceId and enhancing error handling. Overall, the changes aim to streamline resource management without altering existing functionalities.

Changes

File Path Change Summary
client/src/ui/components/bank/LiquidityTable.tsx Reformatting of filteredResources computation for improved readability; unchanged filtering logic.
client/src/ui/components/trading/MarketOrderPanel.tsx Updated props from resource to resourceId, adjusted resource access logic, and enhanced error handling.
client/src/ui/components/trading/MarketResourceSideBar.tsx Changed filtering logic to use RESOURCE_TIERS and updated props to utilize resourceId.

Assessment against linked issues

Objective Addressed Explanation
Mithril listed incorrectly in sequence in market (#2064) It is unclear if the changes directly address the listing issue.

Possibly related PRs

  • [client] orderbook rounds price to 2 decimals #2053: The changes in LiquidityResourceRow.tsx involve formatting numerical outputs, which relates to the filteredResources computation in LiquidityTable.tsx as both components handle resource-related data and display.

Suggested reviewers

  • ponderingdemocritus

Poem

In the land of trades and resources bright,
A table of liquidity shines with delight.
With IDs now clear and logic refined,
The market's secrets are easier to find.
So hop along, dear friends, take a look,
For clarity blooms in every nook! 🐇✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

🧹 Outside diff range and nitpick comments (4)
client/src/ui/components/trading/MarketResourceSideBar.tsx (1)

45-64: Use strict equality comparison for resource IDs

The comparison operator in the active prop should use strict equality (===) instead of loose equality (==) when comparing resource IDs to ensure type safety.

-                active={selectedResource == resourceId}
+                active={selectedResource === resourceId}
client/src/ui/components/trading/MarketOrderPanel.tsx (3)

75-76: Add null checks for resource properties

While optional chaining is used, the fallback to empty string could be improved to provide better user feedback.

Consider this improvement:

-<ResourceIcon size="sm" resource={resource?.trait || ""} withTooltip={false} />
-<div className="truncate text-xs">{resource?.trait || ""}</div>
+<ResourceIcon size="sm" resource={resource?.trait || "Unknown"} withTooltip={false} />
+<div className="truncate text-xs">{resource?.trait || "Unknown Resource"}</div>

Line range hint 4-6: Missing test coverage for market order functionality

The TODO comment indicates missing tests, which is crucial for market functionality.

Would you like me to help create comprehensive test cases for the market order functionality? This should include:

  • Resource identification
  • Order creation
  • Price calculations
  • Edge cases

Line range hint 191-444: Improve error handling for resource lookup

The OrderRow component makes multiple calls to findResourceById without proper error handling.

Consider consolidating resource lookups:

+const resource = useMemo(() => findResourceById(getDisplayResource), [getDisplayResource]);
+if (!resource) {
+  console.error(`Resource not found: ${getDisplayResource}`);
+  return null;
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b1e8218 and 27ec17a.

📒 Files selected for processing (3)
  • client/src/ui/components/bank/LiquidityTable.tsx (1 hunks)
  • client/src/ui/components/trading/MarketOrderPanel.tsx (2 hunks)
  • client/src/ui/components/trading/MarketResourceSideBar.tsx (3 hunks)
🔇 Additional comments (7)
client/src/ui/components/bank/LiquidityTable.tsx (2)

31-36: Formatting improvement looks good

The reformatting of the filter logic improves readability while maintaining the same functionality.


31-36: ⚠️ Potential issue

Changes don't address Mithril's incorrect position

While the code formatting has been improved, these changes don't fix the core issue mentioned in PR #2064 regarding Mithril's incorrect position in the market sequence. The resource ordering is determined by the RESOURCE_TIERS constant, which needs to be modified to fix Mithril's position as the third rarest resource.

Let's verify the current resource ordering implementation:

client/src/ui/components/trading/MarketResourceSideBar.tsx (3)

3-3: LGTM: Import change aligns with resource sequencing fix

The addition of RESOURCE_TIERS import is appropriate for implementing correct resource ordering.


Line range hint 1-73: Verify changes in production environment

While the implementation looks correct, please ensure to test these changes in a production-like environment to confirm:

  1. Mithril appears in the correct sequence (third rarest)
  2. Other resources maintain their expected order
  3. Price calculations work correctly with the new resource ordering

27-28: Verify RESOURCE_TIERS ordering for Mithril

While using RESOURCE_TIERS is the right approach for maintaining resource order, we should verify that Mithril is correctly positioned as the third rarest resource in the RESOURCE_TIERS constant.

✅ Verification successful

Mithril's position in RESOURCE_TIERS is correct

The verification confirms that Mithril (as Mithral) is correctly positioned in the mythic tier alongside Adamantine and Dragonhide, which represents the rarest resource category in the game's hierarchy: commonuncommonrareuniquemythic.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Mithril's position in RESOURCE_TIERS
# Expected: Mithril should be in the third position of the rarest resources

# Search for RESOURCE_TIERS definition
rg -A 10 "RESOURCE_TIERS.*=.*{" 

# Alternative: Look for any constants or enums defining resource order
ast-grep --pattern 'export const RESOURCE_TIERS = {
  $$$
}'

Length of output: 1995

client/src/ui/components/trading/MarketOrderPanel.tsx (2)

35-35: Improved type safety with ResourcesIds

The change from using resource to resourceId with proper type checking through ResourcesIds enum improves type safety. The memoized resource lookup is also a good optimization.

Also applies to: 43-43, 61-63


Line range hint 446-673: Verify market sequence for Mithril resource

While the code handles resource identifiers correctly, there's no explicit handling of resource sequence or rarity tiers that would address the PR's main objective of fixing Mithril's sequence in the market.

Let's verify the resource sequence implementation:

Consider implementing a dedicated sorting mechanism based on resource rarity tiers to ensure correct resource sequencing in the market.

@edisontim edisontim merged commit ebf6aae into next Nov 15, 2024
8 of 9 checks passed
@edisontim edisontim deleted the raschel/issue2064 branch November 15, 2024 19:56
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.

Mithril listed incorrectly in squence in market (third rarest resource)
2 participants