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

Bugfix #1979 Add more options to UserOrderByInput #1980

Merged
merged 6 commits into from
Jun 17, 2024

Conversation

rahulch07
Copy link
Contributor

@rahulch07 rahulch07 commented May 11, 2024

What kind of change does this PR introduce?

BugFix

Issue Number:

Fixes #1979

Did you add tests for your changes?

Yes

Snapshots/Videos:

Summary

This PR is for changes in talawa-admin for issuse #1979 and #2298 are the changes in talawa-api

Does this PR introduce a breaking change?

Other information

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • New Features

    • Added sorting options for users by creation date in ascending and descending order.
    • Enhanced user search, filtering, and sorting functionalities.
  • Bug Fixes

    • Improved error handling in user data fetching.
  • Tests

    • Introduced new mock data and updated test scenarios for user search, filtering, and sorting.

Copy link

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. Merge conflicts

The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

@rahulch07 rahulch07 changed the title Bugfix 1979 Bugfix #1979 Add more options to UserOrderByInput May 11, 2024
@Cioppolo14
Copy link
Contributor

@rahulch07 Please fix the failing tests.

Copy link
Contributor

coderabbitai bot commented May 19, 2024

Walkthrough

The changes involve updating the UserOrderByInput enum in the GraphQL schema to include sorting options, modifying the USER_LIST query to accept an order parameter, and updating the Users screen component to handle sorting, filtering, and displaying user data. Additionally, new mock data and tests were added to validate these functionalities.

Changes

File(s) Change Summary
schema.graphql Added createdAt_ASC and createdAt_DESC options to UserOrderByInput enum.
src/GraphQl/Queries/Queries.ts Updated USER_LIST query to include $order parameter for sorting user results.
src/screens/Users/Users.tsx Updated imports, destructuring, type definitions, and various functions to support new sorting and filtering functionalities.
src/screens/Users/Users.test.tsx Added new mock data (MOCK_USERS, MOCKS_NEW) and modified tests to validate search, filtering, and sorting functionalities.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant UsersScreen
    participant GraphQLServer

    User->>UsersScreen: Perform Search/Sort
    UsersScreen->>GraphQLServer: Query Users with $order parameter
    GraphQLServer-->>UsersScreen: Return Ordered User List
    UsersScreen-->>User: Display Ordered User List
Loading

Assessment against linked issues

Objective Addressed Explanation
Redesign Fund Pledge Screen, Add/Edit Modals & Add Search/Sort (#1979) The changes focus on user listing and sorting, not on the Pledge screen redesign.

Poem

In the code, we sort and seek,
Users' data, sleek and chic.
With new queries, tests so grand,
Order flows at our command.
Mocking data, tests anew,
For a UI bright and true.
🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 843d265 and c56af0c.
Files selected for processing (3)
  • schema.graphql (1 hunks)
  • src/GraphQl/Queries/Queries.ts (2 hunks)
  • src/screens/Users/Users.tsx (11 hunks)
Additional comments not posted (14)
src/screens/Users/Users.tsx (12)

21-21: Added import for ApolloError type.

This ensures proper typing for error handling in Apollo client queries.


45-55: Refactored destructuring of useQuery to include error and rename data to usersData and refetch to refetchUsers.

This change improves readability and makes the code more descriptive, aligning with the new functionalities.


61-61: Added order variable to the useQuery options to support dynamic sorting.

This is a necessary addition to implement the sorting functionality as per the PR objectives.


67-67: Initialization of displayedUsers now directly uses usersData?.users.

This change simplifies the initialization and ensures that displayedUsers is always up to date with the fetched data.


104-104: Redirect non-SUPERADMIN users to the organization list page.

This is a security feature ensuring that only SUPERADMIN users have access to certain functionalities.


124-124: Updated refetchUsers call in handleSearch to include dynamic search parameters.

Enhances the search functionality by allowing dynamic queries based on user input.

Also applies to: 129-129


148-153: Updated refetchUsers in resetAndRefetch to reset search parameters and maintain the current sorting order.

This ensures that the user list is correctly refreshed while maintaining the selected sort order.


162-165: Updated fetchMore to include userType and order, supporting filtered and sorted pagination.

This addition is crucial for maintaining consistency in the list when loading more users under specific filters and sort orders.


188-189: Added reset of displayedUsers in handleSorting and handleFiltering.

Clearing the displayed users list before applying new filters or sort orders prevents display issues and ensures that users see the correct data.

Also applies to: 217-217


266-266: Conditional rendering based on userType.

This ensures that certain UI elements are only displayed to SUPERADMIN users, adhering to the specified role-based access control.


359-369: Enhanced conditional rendering for displaying no results or user not found messages.

Improves user experience by providing clear feedback when no users match the search criteria or when no users are available.


412-412: Ensured that UsersTableItem is only rendered when there are users to display.

This prevents unnecessary rendering calls and potential errors when the usersData is undefined.

src/GraphQl/Queries/Queries.ts (1)

111-111: Added order parameter to the USER_LIST query to support dynamic sorting of users.

This change aligns with the frontend modifications and enables sorting functionality at the data fetching level.

Also applies to: 120-120

schema.graphql (1)

1443-1444: The addition of createdAt_ASC and createdAt_DESC to UserOrderByInput enables sorting by creation date, which aligns with the PR objectives.

Verification successful

The addition of createdAt_ASC and createdAt_DESC to UserOrderByInput has been successfully integrated into the codebase. The search results show multiple instances where these sorting options are used in TypeScript files, confirming their implementation.

  • Instances of createdAt_ASC and createdAt_DESC were found in various TypeScript files, indicating that the new sorting options are being utilized.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of the new sorting options in backend and frontend.

# Test: Search for the usage of `UserOrderByInput` in backend and frontend files.
fd 'schema.graphql' --exec rg 'UserOrderByInput'
fd '.tsx$|.ts$' --exec rg 'UserOrderByInput'

Length of output: 234



Script:

#!/bin/bash
# Description: Verify the integration of the new sorting options `createdAt_ASC` and `createdAt_DESC` in backend and frontend files.

# Test: Search for the usage of `createdAt_ASC` and `createdAt_DESC` in TypeScript files.
fd '.tsx$|.ts$' --exec rg 'createdAt_ASC'
fd '.tsx$|.ts$' --exec rg 'createdAt_DESC'

Length of output: 1708

Copy link

codecov bot commented May 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.39%. Comparing base (843d265) to head (889cb5a).
Report is 27 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1980      +/-   ##
===========================================
+ Coverage    98.26%   98.39%   +0.13%     
===========================================
  Files          210      210              
  Lines         5712     5810      +98     
  Branches      1705     1719      +14     
===========================================
+ Hits          5613     5717     +104     
+ Misses          93       87       -6     
  Partials         6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@palisadoes
Copy link
Contributor

Please get the test code coverage of the patch higher

@rahulch07
Copy link
Contributor Author

Yes, making test cases.

Copy link

github-actions bot commented Jun 4, 2024

This pull request did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please verify it has no conflicts with the develop branch and rebase if needed. Mention it now if you need help or give permission to other people to finish your work.

@github-actions github-actions bot added the no-pr-activity No pull request activity label Jun 4, 2024
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

Commits

Files that changed from the base of the PR and between c56af0c and b452856.

Files selected for processing (1)
  • src/screens/Users/Users.test.tsx (5 hunks)
Additional context used
GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
src/screens/Users/Users.test.tsx

[failure] 15-15:
'"./UsersMocks"' has no exported member named 'MOCKS4'. Did you mean 'MOCKS'?

src/screens/Users/Users.test.tsx Outdated Show resolved Hide resolved
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b452856 and 889cb5a.

Files selected for processing (1)
  • src/screens/Users/Users.test.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/screens/Users/Users.test.tsx

@github-actions github-actions bot removed the no-pr-activity No pull request activity label Jun 5, 2024
Copy link

This pull request did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please verify it has no conflicts with the develop branch and rebase if needed. Mention it now if you need help or give permission to other people to finish your work.

@github-actions github-actions bot added the no-pr-activity No pull request activity label Jun 16, 2024
@palisadoes palisadoes merged commit ff79bd3 into PalisadoesFoundation:develop Jun 17, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-pr-activity No pull request activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants