giovabattelli / FinishLine

Our project management dashboard, v5
https://finishlinebyner.com
GNU Affero General Public License v3.0
0 stars 0 forks source link

[Stats Page] - Create Delete Graph Collection Endpoint #7

Open giovabattelli opened 1 day ago

giovabattelli commented 1 day ago

Description

We need to create an endpoint to soft delete a graph collection. This endpoint should be in the statistics router under the route ‘statistics/:graphCollectionId/delete’ and should take in the graph collection id.

Be sure to include unit tests and screenshots of postman manual tests to ensure everything is working correctly.

Acceptance Criteria

a new endpoint is created in the statistics router under the route ‘statistics/:graphCollectionId/delete’ that soft deletes a graph collection. unit tests and postman screenshot

Proposed Solution

Take a look at some of the other get endpoints we have on Finishline and use it as a reference for this endpoint.

Mocks

No response

trysherpa[bot] commented 1 day ago

Please note, Sherpa may occasionally provide incomplete or inaccurate information. Always verify critical details and double-check suggested changes before implementation.

Summary of the Problem

The issue requires the creation of a new endpoint in the statistics router to soft delete a graph collection. The endpoint should be accessible via the route statistics/:graphCollectionId/delete, and it should accept the graph collection ID as a parameter.

Relevant Files

Guidance for Code Changes

  1. StatisticsRouter.js

    • Locate the section where existing routes are defined.
    • Add a new route for the soft delete operation:
      router.delete('/statistics/:graphCollectionId/delete', graphCollectionController.softDelete);
  2. GraphCollectionController.js

    • Implement the softDelete function:
      • Retrieve the graphCollectionId from the request parameters.
      • Use the model to find the graph collection and mark it as deleted (e.g., by setting a deletedAt timestamp).
      • Respond with an appropriate status and message.
        async softDelete(req, res) {
        const { graphCollectionId } = req.params;
        // Logic to soft delete the graph collection
        }
  3. GraphCollectionModel.js

    • Ensure that your model supports soft deletion. If you have a deletedAt field, make sure it is utilized in your soft delete logic.
  4. StatisticsRouter.test.js

    • Create unit tests for the new endpoint:
      • Test that the endpoint returns the correct status when a valid ID is provided.
      • Test that the graph collection is marked as deleted in the database.
      • Include tests for invalid IDs or unauthorized access.

Summary

To implement the soft delete endpoint, you will need to add a new route in StatisticsRouter.js, implement the deletion logic in GraphCollectionController.js, and ensure your model supports soft deletion. Additionally, don't forget to write unit tests to validate the new functionality. This approach will ensure that the endpoint is integrated correctly and performs as expected within the overall architecture of the application.