Skip to content

Comments

Fetch weekly data fixes and other UI minor fixes#341

Merged
RanaBug merged 1 commit intostagingfrom
feat/px-points-migration-board
Jun 19, 2025
Merged

Fetch weekly data fixes and other UI minor fixes#341
RanaBug merged 1 commit intostagingfrom
feat/px-points-migration-board

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Jun 19, 2025

Description

  • Fetch weekly data fixes and other UI minor fixes

How Has This Been Tested?

  • Existing Unit Tests and Manual testing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • New Features

    • Added a tooltip explaining the gas amount used for asset migration in the leaderboard.
  • Improvements

    • Updated points cards to display a dash ("-") instead of zero when data is missing or unavailable.
    • The total gas value now displays with a dollar sign for clarity.
    • Leaderboard data now refreshes automatically when returning to the app for more up-to-date information.
  • Bug Fixes

    • Adjusted test coverage to correctly reflect fallback display behavior for missing data.

@RanaBug RanaBug requested a review from IAmKio June 19, 2025 10:25
@RanaBug RanaBug self-assigned this Jun 19, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 19, 2025

Walkthrough

This update introduces UI improvements and data handling adjustments to leaderboard points cards. It adds a tooltip to the GasNewDropCard, updates conditional rendering for points display, makes the points prop optional, and removes default zero fallbacks. The useLeaderboardData hook is refactored to simplify its API and enhance data freshness.

Changes

File(s) Change Summary
src/apps/leaderboard/components/PointsCards/GasNewDropCard.tsx Added a tooltip with hover animation and updated container classes for positioning.
src/apps/leaderboard/components/PointsCards/OverviewPointsCard.tsx Introduced conditional rendering to show '-' when index is -1 instead of displaying zero points.
src/apps/leaderboard/components/PointsCards/PointsCard.tsx Made points prop optional; displays '-' if points are undefined/null instead of defaulting to zero.
src/apps/leaderboard/components/PointsCards/tests/OverviewPointsCard.test.tsx Updated test to expect four fallback '-' placeholders instead of two for missing data scenarios.
src/apps/leaderboard/components/PxPointsSummary/PxPointsSummary.tsx Removed default zero fallback for points props; now passes undefined if data is missing.
src/apps/leaderboard/hooks/useLeaderboardData.tsx Refactored to remove timeTab parameter and logic; enabled refetch on window focus for queries.
src/apps/leaderboard/index.tsx Updated useLeaderboardData hook usage (no parameter); prepended '$' to gas display.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LeaderboardPage
    participant useLeaderboardData
    participant API

    User->>LeaderboardPage: Visit leaderboard
    LeaderboardPage->>useLeaderboardData: Call hook (no timeTab)
    useLeaderboardData->>API: Fetch leaderboard data (with refetchOnFocus)
    API-->>useLeaderboardData: Return data
    useLeaderboardData-->>LeaderboardPage: Provide leaderboard data
    LeaderboardPage->>User: Render PointsCards (with updated points logic and tooltips)
    Note over LeaderboardPage: Tooltip appears on hover in GasNewDropCard
Loading

Possibly related PRs

Suggested reviewers

  • IAmKio

Poem

A dash for points when data’s shy,
Tooltips now float as you hover by.
No more zeros where none belong,
The cards are clearer, the UI strong.
With fresher data and styling anew,
This leaderboard’s hopping—thanks to you!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-19T10_27_22_805Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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
Collaborator

@IAmKio IAmKio left a comment

Choose a reason for hiding this comment

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

LGTM

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 comments (1)
src/apps/leaderboard/hooks/useLeaderboardData.tsx (1)

92-130: Optimize weekly data processing to avoid unnecessary computations.

The removal of the timeTab === 'weekly' condition means weekly trading data is always processed, even when the weekly tab is not active. This could impact performance unnecessarily.

Consider adding the timeTab check back or implementing a more efficient data processing strategy:

useEffect(() => {
+ // Only process if weekly data is needed
+ if (timeTab !== 'weekly') return;
+
  if (
    weeklyQuery.data &&
    lastWeeklyQuery.data &&
    !weeklyQuery.isLoading &&
    !lastWeeklyQuery.isLoading
  ) {
    // ... existing processing logic
  }
}, [
  weeklyQuery.data,
  lastWeeklyQuery.data,
  weeklyQuery.isLoading,
  lastWeeklyQuery.isLoading,
  compareIndexes,
+ timeTab,
]);
🧹 Nitpick comments (4)
src/apps/leaderboard/hooks/useLeaderboardData.tsx (1)

37-37: Consider the performance impact of refetchOnFocus.

Adding refetchOnFocus: true to all queries will improve data freshness but may cause unnecessary API calls when users frequently switch between browser tabs/windows. Monitor API usage patterns to ensure this doesn't negatively impact performance.

Also applies to: 46-46, 55-55, 60-60

src/apps/leaderboard/components/PointsCards/GasNewDropCard.tsx (1)

21-24: Enhance tooltip accessibility for better user experience.

The tooltip implementation is functional but could be improved for accessibility. Consider adding keyboard support and ARIA attributes for screen readers.

-<div className="group flex flex-col w-full gap-3 rounded-[10px] p-2 relative">
-  <div className="absolute bottom-full mb-2 left-0 rounded-lg border border-white/[.05] bg-[#25232D] px-2.5 py-2 text-[10px] text-white italic font-normal opacity-0 group-hover:opacity-100 transition-all duration-200 z-10 max-w-max w-fit origin-bottom scale-y-0 group-hover:scale-y-100 transform">
+<div className="group flex flex-col w-full gap-3 rounded-[10px] p-2 relative" tabIndex={0}>
+  <div 
+    className="absolute bottom-full mb-2 left-0 rounded-lg border border-white/[.05] bg-[#25232D] px-2.5 py-2 text-[10px] text-white italic font-normal opacity-0 group-hover:opacity-100 group-focus:opacity-100 transition-all duration-200 z-10 max-w-max w-fit origin-bottom scale-y-0 group-hover:scale-y-100 group-focus:scale-y-100 transform"
+    role="tooltip"
+    aria-label="Gas usage explanation"
+  >
     This is the amount of gas used to migrate your assets over to PillarX.
   </div>
src/apps/leaderboard/components/PointsCards/OverviewPointsCard.tsx (2)

38-42: Consider removing the zero fallback for consistency.

The conditional rendering logic is good, but the || 0 fallback when accessing totalPoints is inconsistent with the new approach of showing dashes for missing data. If a user exists in the leaderboard (index !== -1) but totalPoints is undefined, it will display "0 PX" instead of "-".

Consider this approach for better consistency:

-            {myAllTimeMerged.index === -1
-              ? '-'
-              : formatAmountDisplay(
-                  Math.floor(myAllTimeMerged.entry?.totalPoints || 0)
-                )}
+            {myAllTimeMerged.index === -1 || !myAllTimeMerged.entry?.totalPoints
+              ? '-'
+              : formatAmountDisplay(Math.floor(myAllTimeMerged.entry.totalPoints))}

87-91: Apply the same consistency improvement for weekly points.

Similar to the all-time points, consider removing the zero fallback here as well for consistent handling of missing data.

-            {myWeeklyMerged.index === -1
-              ? '-'
-              : formatAmountDisplay(
-                  Math.floor(myWeeklyMerged.entry?.totalPoints || 0)
-                )}
+            {myWeeklyMerged.index === -1 || !myWeeklyMerged.entry?.totalPoints
+              ? '-'
+              : formatAmountDisplay(Math.floor(myWeeklyMerged.entry.totalPoints))}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f96272 and b5f2ad9.

⛔ Files ignored due to path filters (3)
  • src/apps/leaderboard/components/PointsCards/tests/__snapshots__/GasNewDropCard.test.tsx.snap is excluded by !**/*.snap
  • src/apps/leaderboard/components/PointsCards/tests/__snapshots__/OverviewPointsCard.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • src/apps/leaderboard/components/PointsCards/GasNewDropCard.tsx (1 hunks)
  • src/apps/leaderboard/components/PointsCards/OverviewPointsCard.tsx (2 hunks)
  • src/apps/leaderboard/components/PointsCards/PointsCard.tsx (2 hunks)
  • src/apps/leaderboard/components/PointsCards/tests/OverviewPointsCard.test.tsx (1 hunks)
  • src/apps/leaderboard/components/PxPointsSummary/PxPointsSummary.tsx (2 hunks)
  • src/apps/leaderboard/hooks/useLeaderboardData.tsx (4 hunks)
  • src/apps/leaderboard/index.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/apps/leaderboard/components/PointsCards/OverviewPointsCard.tsx (1)
src/utils/number.tsx (1)
  • formatAmountDisplay (3-33)
src/apps/leaderboard/components/PointsCards/PointsCard.tsx (1)
src/utils/number.tsx (1)
  • formatAmountDisplay (3-33)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: unit-tests
  • GitHub Check: lint
  • GitHub Check: build
🔇 Additional comments (7)
src/apps/leaderboard/hooks/useLeaderboardData.tsx (1)

27-27: To accurately locate all hook usages across .ts and .tsx files, let’s broaden the search without relying on unsupported file-type filters:

#!/bin/bash
# Search for useLeaderboardData calls in all TS/TSX files
rg -n 'useLeaderboardData\(' --glob '*.ts' --glob '*.tsx'
src/apps/leaderboard/components/PointsCards/tests/OverviewPointsCard.test.tsx (1)

75-75: Test update aligns with component behavior changes.

The increase from 2 to 4 expected fallback dashes correctly reflects the updated component logic that now displays more dashes for missing data.

src/apps/leaderboard/index.tsx (2)

64-64: Hook call correctly updated to match new signature.

The removal of the timeTab argument aligns perfectly with the refactored useLeaderboardData hook signature.


196-196: Improved gas amount display with currency symbol.

Adding the dollar sign prefix makes the gas cost display more intuitive and consistent with other monetary values in the UI.

src/apps/leaderboard/components/PxPointsSummary/PxPointsSummary.tsx (1)

112-112: Verify PointsCard handles undefined points prop correctly.

Removing the || 0 fallbacks is good for explicit handling of missing data, but ensure the PointsCard component properly handles undefined values for the points prop.

#!/bin/bash
# Description: Verify PointsCard component handles undefined points prop
# Expected: Component should handle undefined/null points gracefully

# Search for PointsCard component implementation
ast-grep --pattern 'const PointsCard = ({ $$$, points, $$$ }: $$$) => {
  $$$
}'

# Also check for points prop usage in the component
rg -A 10 -B 5 'points.*\?' src/apps/leaderboard/components/PointsCards/PointsCard.tsx

Also applies to: 125-125

src/apps/leaderboard/components/PointsCards/PointsCard.tsx (2)

11-11: Good approach to making points optional.

Making the points prop optional properly supports the new data handling approach where missing points should be displayed as dashes rather than defaulting to zero.


42-42: Excellent null handling implementation.

The != null check properly handles both null and undefined values, and Math.floor() is only called when points is guaranteed to be a number. This is a clean and consistent approach to displaying missing data.

@cloudflare-workers-and-pages
Copy link

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: b5f2ad9
Status: ✅  Deploy successful!
Preview URL: https://947d2560.x-e62.pages.dev
Branch Preview URL: https://feat-px-points-migration-boa.x-e62.pages.dev

View logs

@RanaBug RanaBug merged commit 9672ed1 into staging Jun 19, 2025
7 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jun 26, 2025
3 tasks
@coderabbitai coderabbitai bot mentioned this pull request Aug 19, 2025
3 tasks
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.

2 participants