Skip to content

Implement a GraphQL Mutation to update the status/progress (e.g., change from "Planning to Watch" to "Watching", or update episode 12 to 13). #81

@vitorhugo-java

Description

@vitorhugo-java

Now that users can query their library (PR #88) and add/remove items (Issue #80), they need the ability to update their tracking progress. This issue focuses on creating a mutation to modify fields within an existing UserMediaList record, such as changing the status from "Planning to Watch" to "Watching", or incrementing the episode/chapter progress (e.g., from episode 12 to 13).

Also must be introduced dataPlanned in userlibrary, which will be store when the user put the media on their plan list.

Acceptance Criteria:

  • Schema Updates:

    • Create a new input type UpdateUserMediaInput containing optional fields: status (ID - FK), progress (Int), score (Double), startDate (Date), finishDate (Date), media_id (Media FK), and note (String).

    • Update the mutation addMediaToUserLibrary to userMediaProgress( input: UpdateUserMediaInput!): UserMediaList to the GraphQL schema. This mutation must be capable of add and update userMedia library, for this must utilize user_id and media_id.

    • Create mutation to user create, update, get and delete a status to his profile.

  • Controller Layer:

    • Map the mutation must use @PreAuthorize("hasRole('user')") security.

    • Ensure the update strictly targets the authenticated user's record for the provided mediaId.

  • Service & Repository Layer:

    • Fetch the existing UserMediaList record using the authenticated or passed though query user's ID and the provided mediaId.

    • Apply the updates from the input object. Validate that the provided status maps correctly to the existing MediaStatus entities defined in PR feat: GraphQL query for user media library (findUserMediaLibrary) #88.

    • Save and return the updated entity.

  • Database/Enum:

    • Add the follwing status (on enum StatusType and migration) - main status -: Planning, In Progress, Dropped and Paused.

    • Remove WATCHING and PLAN_TO_WATCH.

  • Testing:

    • Add unit and integration tests verifying that progress and status can be updated successfully.

    • Include boundary tests (e.g., ensuring a user cannot update another user's progress, handling invalid status strings gracefully, and testing out-of-bounds progress values).

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions