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

Transform players array in findOpenGames and ensure filtered results include id and username only #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rmmahmou
Copy link
Collaborator

@rmmahmou rmmahmou commented Dec 8, 2024

Issue number #6

Relevant issue number

  • Resolves #

Please check the following

  • Do the tests still pass? (see Run the Tests)
  • Is the code formatted properly? (see Linting (Formatting))
  • For New Features:
    • Have tests been added to cover any new features or fixes?
    • Has the documentation been updated accordingly?

Please describe additional details for testing this change

This pull request updates the findOpenGames function in the backend to ensure that the players array in each game is transformed to include only the id and username fields. This is necessary for the frontend to properly display player data while keeping unnecessary and sensitive information excluded.

Changes Made:

Updated the findOpenGames function in api/hooks/customGameHook/index.js:

  • Transformed the players array using the map() method to retain only id and username.
  • Filtered games to include only those with fewer than 2 players.
  • Enhanced error handling to check for empty game results.
  • Maintained all other game properties while transforming the players array.
Screen Shot 2024-12-11 at 12 45 36 AM

Testing:

Unit tests were created and executed to validate
The unit tests ensure consistent behavior and compatibility with the frontend requirements.

@rmmahmou rmmahmou self-assigned this Dec 8, 2024
@rmmahmou rmmahmou changed the title Transform players array in findOpenGames to include only id and username Transform players array in findOpenGames and ensure filtered results include id and username only Dec 8, 2024
@Hakaabi Hakaabi added this to the Sprint 5 - Coretask milestone Dec 11, 2024
@Hakaabi Hakaabi self-requested a review December 12, 2024 20:53
Copy link

@Hakaabi Hakaabi left a comment

Choose a reason for hiding this comment

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

Changes here looks great!

@Hakaabi Hakaabi added the enhancement New feature or request label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor findOpenGames to include id and username for players in the game data response.
2 participants