Skip to content

fix: profile page not loading #2023

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

Merged
merged 4 commits into from
Jun 20, 2025
Merged

fix: profile page not loading #2023

merged 4 commits into from
Jun 20, 2025

Conversation

kemuru
Copy link
Contributor

@kemuru kemuru commented Jun 11, 2025

PR-Codex overview

This PR introduces a new utility function sanitizeFilter for cleaning up filter objects and integrates it into various components and hooks, improving the handling of filters in queries. It also adds a calculateStats function to compute statistics based on user data.

Detailed summary

  • Added sanitizeFilter function in web/src/utils/sanitizeFilter.ts to clean filter objects.
  • Updated formattedValue in web/src/components/NumberDisplay.tsx to use commify.
  • Integrated sanitizeFilter in useUserQuery and useCasesQuery hooks for improved filter handling.
  • Added calculateStats function in web/src/pages/Profile/index.tsx to compute total and ruled cases based on user data.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes
    • Improved data accuracy by ensuring user queries with different filter criteria are cached and displayed correctly.
  • New Features
    • Enhanced profile statistics with refined case count calculations based on filter criteria.
    • Introduced filter sanitization to improve query consistency and reliability.
  • Enhancements
    • Numbers displayed with improved formatting for better readability.

Copy link
Contributor

coderabbitai bot commented Jun 11, 2025

Walkthrough

The update introduces a sanitizeFilter utility to clean filter objects by removing empty arrays before use. This sanitized filter is applied in user and case query hooks to refine cache keys, query selection, and variables. Additionally, dispute statistics calculation in the Profile page is centralized with a new helper function. The NumberDisplay component now formats numbers with thousands separators.

Changes

File(s) Change Summary
web/src/hooks/queries/useUser.ts, web/src/hooks/queries/useCasesQuery.ts Added sanitizeFilter usage to preprocess where filters, updating cache keys, query selection, and variables.
web/src/utils/sanitizeFilter.ts Added new utility function sanitizeFilter to remove empty arrays from filter objects and return cleaned filters.
web/src/pages/Profile/index.tsx Added calculateStats function to compute dispute statistics based on user data and filters; integrated with Profile component using useMemo.
web/src/components/NumberDisplay.tsx Applied commify to formatted numbers for improved readability with thousands separators.

Poem

A filter clean and neat,
No empty arrays to greet.
Queries now hop with grace,
Stats aligned in their place.
Numbers dance with commas bright,
Fresh data in every sight!
🐇✨🥕

Suggested labels

Type: Bug :bug:, Package: Web

Suggested reviewers

  • alcercu

📜 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 7449259 and a35ceb0.

📒 Files selected for processing (1)
  • web/src/components/NumberDisplay.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet-devtools
  • GitHub Check: Header rules - kleros-v2-testnet-devtools
  • GitHub Check: Pages changed - kleros-v2-testnet-devtools
  • GitHub Check: Redirect rules - kleros-v2-university
  • GitHub Check: Header rules - kleros-v2-university
  • GitHub Check: Pages changed - kleros-v2-university
  • GitHub Check: Analyze (javascript)
  • GitHub Check: SonarCloud
  • GitHub Check: dependency-review
  • GitHub Check: contracts-testing
🔇 Additional comments (2)
web/src/components/NumberDisplay.tsx (2)

37-37: LGTM! Enhanced numeric formatting improves readability.

The application of commify to the formatted value will add thousands separators, making numbers more readable for users. The implementation correctly chains the formatting functions.


5-5: Verify the commify utility exists and functions correctly.

The import looks correct, but ensure the commify utility is properly implemented and handles string inputs as expected.

#!/bin/bash
# Description: Verify the commify utility exists and examine its implementation
# Expected: The utility should exist and handle string/number formatting correctly

# Check if the commify utility file exists
fd -t f commify

# Search for the commify function definition
ast-grep --pattern 'export $_ commify'

# Search for commify function usage patterns
rg -A 3 -B 3 'commify'
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 or @coderabbitai title 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

netlify bot commented Jun 11, 2025

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit a35ceb0
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet/deploys/6853ec5e6c11b10008dc799b
😎 Deploy Preview https://deploy-preview-2023--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Jun 11, 2025

Deploy Preview for kleros-v2-testnet-devtools ready!

Name Link
🔨 Latest commit a35ceb0
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet-devtools/deploys/6853ec5e772b520008968378
😎 Deploy Preview https://deploy-preview-2023--kleros-v2-testnet-devtools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Jun 11, 2025

Deploy Preview for kleros-v2-university failed. Why did it fail? →

Name Link
🔨 Latest commit a35ceb0
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-university/deploys/6853ec5efd90ac00086a3530

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4adedb5 and 929955c.

📒 Files selected for processing (1)
  • web/src/hooks/queries/useUser.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: contracts-testing
  • GitHub Check: Analyze (javascript)
  • GitHub Check: SonarCloud

@kemuru kemuru changed the title fix: add where to the key fix: profile page not loading Jun 11, 2025
Copy link

netlify bot commented Jun 11, 2025

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit a35ceb0
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-neo/deploys/6853ec5edfbd780008efad9d
😎 Deploy Preview https://deploy-preview-2023--kleros-v2-neo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kemuru kemuru marked this pull request as ready for review June 18, 2025 23:19
@kemuru kemuru requested a review from a team as a code owner June 18, 2025 23:19
@kemuru kemuru requested a review from alcercu June 18, 2025 23:19
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: 2

🧹 Nitpick comments (1)
web/src/utils/sanitizeFilter.ts (1)

4-4: Consider using explicit typing for the destructured parameter.

The underscore parameter in the filter callback could be more explicit to improve readability.

Apply this diff for better readability:

-  const cleaned = Object.fromEntries(Object.entries(f).filter(([_, v]) => !(Array.isArray(v) && v.length === 0)));
+  const cleaned = Object.fromEntries(Object.entries(f).filter(([key, v]) => !(Array.isArray(v) && v.length === 0)));
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 929955c and 7449259.

📒 Files selected for processing (4)
  • web/src/hooks/queries/useCasesQuery.ts (2 hunks)
  • web/src/hooks/queries/useUser.ts (2 hunks)
  • web/src/pages/Profile/index.tsx (3 hunks)
  • web/src/utils/sanitizeFilter.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/hooks/queries/useUser.ts
⏰ Context from checks skipped due to timeout of 90000ms (17)
  • GitHub Check: Redirect rules - kleros-v2-university
  • GitHub Check: Redirect rules - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-university
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-neo
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-university
  • GitHub Check: Pages changed - kleros-v2-neo
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: dependency-review
  • GitHub Check: contracts-testing
  • GitHub Check: Analyze (javascript)
  • GitHub Check: SonarCloud
  • GitHub Check: Mend Security Check
🔇 Additional comments (3)
web/src/hooks/queries/useCasesQuery.ts (2)

75-90: Good implementation of filter sanitization.

The consistent application of sanitizeFilter across query key, document selection, and variables ensures proper cache behavior and query execution. The logic correctly uses different query documents based on whether a filter is present.


95-111: Consistent filter sanitization applied correctly.

The implementation mirrors the pattern used in useCasesQuery, ensuring consistency across the codebase. The inline enabled flag is also a good simplification.

web/src/pages/Profile/index.tsx (1)

99-102: Good use of useMemo for performance optimization.

The memoization of the statistics calculation with proper dependencies (userData?.user and decodedFilter) ensures the calculation only runs when necessary, improving performance.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 18, 2025
Copy link

codeclimate bot commented Jun 19, 2025

Code Climate has analyzed commit a35ceb0 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Style 1

View more on Code Climate.

Copy link

Copy link
Contributor

@alcercu alcercu left a comment

Choose a reason for hiding this comment

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

lgtm

@alcercu alcercu merged commit b38c702 into dev Jun 20, 2025
20 of 26 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