Skip to content

Comments

Added new drop time and further QA minor fixes#339

Merged
RanaBug merged 2 commits intostagingfrom
feat/px-points-migration-board
Jun 18, 2025
Merged

Added new drop time and further QA minor fixes#339
RanaBug merged 2 commits intostagingfrom
feat/px-points-migration-board

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Jun 18, 2025

Description

  • Added new drop time and further QA 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 dynamic countdown display for the next drop time in the leaderboard, showing days, hours, and minutes remaining.
  • Improvements
    • Leaderboard entries now display the next drop time based on actual trading data, enhancing accuracy and relevance.
    • Leaderboard summary numbers (total volume and gas) use improved formatting for better readability.
    • Leaderboard data is now sorted by total points in descending order for clearer ranking.
    • Responsive design improvements for token grids on tablet and mobile devices.
  • Bug Fixes
    • Ensured consistent and accurate time formatting in leaderboard card displays.
  • Tests
    • Updated tests to reflect new time formatting and ensure consistent behavior across time-dependent features.

@RanaBug RanaBug requested a review from IAmKio June 18, 2025 14:38
@RanaBug RanaBug self-assigned this Jun 18, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

Walkthrough

A new FormattedNewDrop React component was introduced to display time differences in a user-friendly format. The GasNewDropCard and related tests were updated to use this component. The leaderboard logic and types were adjusted to support and propagate a new newDropTime property, and sorting was added to leaderboard utilities. Minor UI and formatting improvements were also made.

Changes

Files/Groups Change Summary
src/apps/leaderboard/components/PointsCards/FormattedNewDrop.tsx Added new FormattedNewDrop component to display formatted time differences.
src/apps/leaderboard/components/PointsCards/GasNewDropCard.tsx Updated to use FormattedNewDrop for displaying drop time; adjusted timestamp calculation and imports.
src/apps/leaderboard/components/PointsCards/tests/GasNewDropCard.test.tsx Updated tests to mock time, use milliseconds for newDropTime, and assert new formatted output.
src/apps/leaderboard/components/PxPointsSummary/PxPointsSummary.tsx Changed newDropTime prop to use dynamic value from trading entry instead of hardcoded zero.
src/apps/leaderboard/hooks/useLeaderboardData.tsx Added newDropTime property to each entry in leaderboard data from API.
src/types/api.ts Extended LeaderboardTableData type with optional newDropTime property.
src/apps/leaderboard/utils/index.tsx Added sorting by descending totalPoints to leaderboard data merge functions.
src/apps/leaderboard/index.tsx Updated value formatting for totalVolume and totalGas using a utility function.
src/apps/pillarx-app/components/TopTokens/TopTokens.tsx Improved responsive grid layout with explicit tablet and mobile column classes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GasNewDropCard
    participant FormattedNewDrop

    User->>GasNewDropCard: Render with newDropTime
    GasNewDropCard->>FormattedNewDrop: Pass timestamp (newDropTime + 24h)
    FormattedNewDrop->>FormattedNewDrop: Calculate time difference
    FormattedNewDrop-->>GasNewDropCard: Display formatted time (Xd Xh Xm)
Loading

Suggested reviewers

  • IAmKio

Poem

A new drop is near, the clock ticks away,
Now shown in style—just minutes, hours, days!
With data well-sorted and numbers so neat,
The leaderboard shines, its look now complete.
🕒🐇 Hooray for fresh features, and code oh-so-sweet!

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-18T15_02_34_693Z-debug-0.log


📜 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 355ec42 and cd9f733.

📒 Files selected for processing (1)
  • src/apps/pillarx-app/components/TopTokens/TopTokens.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/apps/pillarx-app/components/TopTokens/TopTokens.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint
  • GitHub Check: unit-tests
  • GitHub Check: build
✨ 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
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: 4

🧹 Nitpick comments (7)
src/types/api.ts (1)

865-865: Specify time unit and intent for newDropTime.

Readers can’t infer whether the value is seconds or milliseconds, nor whether it refers to “last update” or “next drop”. A terse JSDoc comment eliminates that ambiguity and prevents subtle bugs elsewhere.

   newDropTime?: number;
+  /**
+   * Unix-timestamp in **milliseconds** marking when the user’s points were last
+   * updated (UI adds +24 h to display the next drop).
+   */
src/apps/leaderboard/utils/index.tsx (2)

162-164: Sorting ok, but keep original arrays pristine.

Array.sort mutates the array in-place.
Here you sort a freshly-spread array, so it’s safe, yet an explicit clone (e.g. .toSorted(...) in modern TS or slice().sort(...)) removes any doubt.

-  return [...processedTradingData, ...unprocessedMigrationData].sort(
-    (a, b) => b.totalPoints - a.totalPoints
-  );
+  return [...processedTradingData, ...unprocessedMigrationData]
+    .slice()
+    .sort((a, b) => b.totalPoints - a.totalPoints);

230-230: Apply the same immutability pattern here for consistency.

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

46-49: Time arithmetic belongs outside the render tree.

Adding 24 h inline mixes presentation with business logic and forces every render to redo the math.
Compute the “next drop timestamp” once (e.g. in the hook) and pass it directly:

-<FormattedNewDrop timestamp={newDropTime + 24 * 60 * 60 * 1000} />
+<FormattedNewDrop timestamp={nextDropTimestamp} />

This also avoids double-adding 24 h if upstream code starts doing it later.

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

196-197: Currency symbol inconsistency

totalVolume is prefixed with $, but totalGas is shown bare.
If totalGas is also a monetary figure (USD), add the symbol; if it is a unit of gas, clarify via a suffix (e.g. gwei) to avoid user confusion.

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

28-40: Redundant state initialisation & tight interval

setTimeLeft(getNextDrop()) is called:

  1. In the useState initializer.
  2. Immediately again inside useEffect.

The second call is redundant.
Additionally, running the interval every 60 000 ms means the displayed minute ticks drift relative to the real minute boundary.
Consider computing the remaining milliseconds to the next full minute and scheduling the first timeout accordingly, then switching to a 60 000 ms interval.


44-60: Accessibility: missing aria-label

The countdown is purely numeric. Add an aria-label that conveys the meaning for screen-reader users, e.g.:

<p
  aria-label={`${days} days ${hours} hours ${minutes} minutes until next drop`}
  className="text-sm text-white font-semibold"
>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 77016bc and 355ec42.

⛔ Files ignored due to path filters (1)
  • src/apps/leaderboard/components/PointsCards/tests/__snapshots__/GasNewDropCard.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (9)
  • src/apps/leaderboard/components/PointsCards/FormattedNewDrop.tsx (1 hunks)
  • src/apps/leaderboard/components/PointsCards/GasNewDropCard.tsx (2 hunks)
  • src/apps/leaderboard/components/PointsCards/tests/GasNewDropCard.test.tsx (1 hunks)
  • src/apps/leaderboard/components/PxPointsSummary/PxPointsSummary.tsx (1 hunks)
  • src/apps/leaderboard/hooks/useLeaderboardData.tsx (1 hunks)
  • src/apps/leaderboard/index.tsx (2 hunks)
  • src/apps/leaderboard/utils/index.tsx (2 hunks)
  • src/apps/pillarx-app/components/TopTokens/TopTokens.tsx (1 hunks)
  • src/types/api.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/apps/leaderboard/index.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 (3)
src/apps/leaderboard/hooks/useLeaderboardData.tsx (1)

73-74: Let’s retry fetching the field without process-substitution:

#!/bin/bash
# Inspect a sample API payload for `pointsUpdatedAt` (avoid /dev/fd)
curl -s https://api.example.com/leaderboard | jq '.results[0].pointsUpdatedAt'
src/apps/leaderboard/components/PxPointsSummary/PxPointsSummary.tsx (1)

134-135: Good call – newDropTime now flows from real data.

The prop change removes the magic 0 and aligns with the new API field.

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

7-8: 👍 Nice extraction of formatting logic into FormattedNewDrop.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jun 18, 2025

Deploying x with  Cloudflare Pages  Cloudflare Pages

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

View logs

@github-actions github-actions bot temporarily deployed to Preview (feat/px-points-migration-board) June 18, 2025 15:00 Inactive
@RanaBug RanaBug merged commit 4f96272 into staging Jun 18, 2025
7 of 8 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