Skip to content

change of leaderboard last sync#266

Merged
RanaBug merged 1 commit intostagingfrom
fix/PRO-3014/leaderboard-improvements
Mar 24, 2025
Merged

change of leaderboard last sync#266
RanaBug merged 1 commit intostagingfrom
fix/PRO-3014/leaderboard-improvements

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Mar 24, 2025

Description

How Has This Been Tested?

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
    • Leaderboard displays enhanced metrics, now showing transaction fee values in USD with rewards eligibility indicators.
    • Last update times for leaderboard data are now directly based on your wallet address for more accurate sync information.
  • Style
    • Improved wallet information layout with refined alignment and icon sizing for better visual clarity.
  • Refactor
    • Streamlined data handling and state management to support these display updates.

@RanaBug RanaBug requested a review from IAmKio March 24, 2025 15:17
@RanaBug RanaBug self-assigned this Mar 24, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2025

Walkthrough

This pull request updates several components to adjust data representation and UI layout. Test data for the leaderboard component now reflects transaction fees instead of raw gas counts and includes additional deployment eligibility flags and timestamps. The UserInfo display has minor styling changes. The leaderboard index replaces several state variables with direct wallet address usage to retrieve user data. Import paths for date conversion helper functions have been updated in Token Atlas files, while redundant conversion functions are removed. API types are revised to match the new transaction fee data structure and deployment eligibility.

Changes

File(s) Change Summary
src/apps/leaderboard/components/LeaderboardTab/test/LeaderboardTab.test.tsx Updated mockData: renamed gasCount to txFeesUsd, added totalTxFeesUsd, isDeployPointsEligible, and pointsUpdatedAt.
src/apps/leaderboard/components/UserInfo/UserInfo.tsx Modified layout and styling: changed container alignment from items-end to items-center and adjusted CopySuccessIcon size from 16 to 15.
src/apps/leaderboard/index.tsx Replaced multiple state variables managing fetch timestamps with a single wallet address variable using useWalletAddress; now retrieves user sync data for weekly/all-time views directly.
src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx
src/apps/token-atlas/reducer/tokenAtlasSlice.ts
Updated import paths for convertDateToUnixTimestamp to new location (../../../../utils/common and ../../../utils/common respectively).
src/apps/token-atlas/utils/converters.ts Removed exported conversion functions: convertDateToUnixTimestamp and convertUnixTimestampToDate.
src/types/api.ts Modified PointsResult type: removed totalGasUsed and gasCount; added totalTxFeesUsd, txFeesUsd, isDeployPointsEligible, and pointsUpdatedAt. Also added new type PointsEligibilityData.
src/utils/common.ts Added new function convertDateToUnixTimestamp that converts a Date to a Unix timestamp (in seconds).

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant L as Leaderboard Component
    participant W as Wallet Hook
    participant D as Data Source

    U->>L: Open leaderboard page
    L->>W: Request wallet address
    W-->>L: Provide wallet address
    L->>D: Retrieve weekly and all-time data using wallet address
    D-->>L: Return corresponding user data
    L->>L: Render UI with last sync time based on active tab
Loading

Possibly related PRs

Suggested Reviewers

  • IAmKio

Poem

In a field of code so bright,
I hop along with pure delight.
Changing tests and UI in sight,
Data flows now crisp and light.
I, the rabbit, cheer this flight! 🐇💻
CodeRabbit Inc. codes all night.
Hop on, let’s make it right!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0133289 and 3616993.

⛔ Files ignored due to path filters (4)
  • src/apps/leaderboard/components/LeaderboardTab/test/__snapshots__/LeaderboardTab.test.tsx.snap is excluded by !**/*.snap
  • src/apps/leaderboard/components/UserInfo/test/__snapshots__/UserInfo.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/PointsTile/test/__snapshots__/PointsTile.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (8)
  • src/apps/leaderboard/components/LeaderboardTab/test/LeaderboardTab.test.tsx (1 hunks)
  • src/apps/leaderboard/components/UserInfo/UserInfo.tsx (1 hunks)
  • src/apps/leaderboard/index.tsx (4 hunks)
  • src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (1 hunks)
  • src/apps/token-atlas/reducer/tokenAtlasSlice.ts (1 hunks)
  • src/apps/token-atlas/utils/converters.ts (0 hunks)
  • src/types/api.ts (1 hunks)
  • src/utils/common.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • src/apps/token-atlas/utils/converters.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: unit-tests
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (13)
src/utils/common.ts (1)

39-41: Good addition of the utility function

The implementation of convertDateToUnixTimestamp correctly converts a Date object to a Unix timestamp by dividing the millisecond timestamp by 1000 and flooring the result. This is a standard and efficient approach.

src/apps/token-atlas/reducer/tokenAtlasSlice.ts (1)

16-16: Import path correctly updated

The import path for convertDateToUnixTimestamp has been correctly updated to reflect its new location in the common utils folder. This ensures the functionality remains intact while improving code organization.

src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (1)

14-15: Import paths correctly updated

The import path for convertDateToUnixTimestamp has been properly updated to source from the common utils, while limitDigits remains imported from the local converters file. This split is appropriate and maintains the functionality of both utilities.

src/apps/leaderboard/components/UserInfo/UserInfo.tsx (2)

117-117: Alignment adjustment improves UI consistency.

Changed vertical alignment from items-end to items-center for better visual balance when displaying the wallet address and copy icon.


122-126: Icon size adjustment ensures visual consistency.

Reduced the CopySuccessIcon size from 16 to 15px to match the CopyIcon size (already 15px at line 130), creating a more consistent UI experience when switching between states.

src/apps/leaderboard/components/LeaderboardTab/test/LeaderboardTab.test.tsx (2)

31-35: Updated property name aligns with API structure changes.

Replaced gasCount with txFeesUsd to reflect the shift from gas metrics to transaction fees in USD, matching the changes in the PointsResult type.


36-42: Added new properties to test data to match API type changes.

The added properties (totalTxFeesUsd, isDeployPointsEligible, and pointsUpdatedAt) ensure the mock data structure correctly reflects the updated PointsResult type, maintaining test validity.

src/types/api.ts (2)

409-411: New type introduced for deployment eligibility tracking.

The PointsEligibilityData type provides a clear structure for tracking which chains a user is eligible for deployment points on.


415-422: API type changes reflect shift from gas metrics to transaction fees.

These changes update the PointsResult type to:

  1. Replace totalGasUsed with totalTxFeesUsd (line 415)
  2. Add deployment eligibility tracking via isDeployPointsEligible (line 419)
  3. Add a timestamp for when points were last updated via pointsUpdatedAt (line 420)
  4. Add transaction fees by chain through txFeesUsd (line 421)

These changes align with the updated leaderboard functionality that now uses transaction fees instead of gas metrics.

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

2-2: Added import for accessing wallet address.

Added the useWalletAddress hook from the transaction kit to directly access the user's wallet address.


33-33: Simplified state management with direct wallet address access.

Replaced multiple state variables tracking fetch timestamps with direct wallet address access, streamlining the component's state management.


137-143: Improved user data lookup with direct wallet matching.

Added direct lookup of user data in both weekly and all-time datasets using the wallet address, which simplifies data access and improves code readability.


154-173: Updated time display logic to use new pointsUpdatedAt property.

Refactored the last sync time display to use the pointsUpdatedAt timestamp from the user's data, providing more accurate synchronization information. The code now properly handles both weekly and all-time views with appropriate conditional rendering.

✨ 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.
    • 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 generate docstrings to generate docstrings for 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.

@cloudflare-workers-and-pages
Copy link

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3616993
Status: ✅  Deploy successful!
Preview URL: https://fab1a9dc.x-e62.pages.dev
Branch Preview URL: https://fix-pro-3014-leaderboard-imp.x-e62.pages.dev

View logs

@RanaBug RanaBug merged commit f8fbb6f into staging Mar 24, 2025
7 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.

2 participants