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 #9

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 at hand is the need to create a new endpoint for soft deleting a graph collection in the statistics router. This endpoint should be accessible via the route statistics/:graphCollectionId/delete and must accept the graphCollectionId as a parameter. Additionally, unit tests and Postman screenshots are required to validate the implementation.

Relevant Files

Suggested Changes

1. Update the Statistics Router

In src/backend/src/routes/statistics.ts, you will need to add a new route for handling the delete request. Here’s a skeleton of what that might look like:

router.delete('/:graphCollectionId/delete', statisticsController.deleteGraphCollection);

2. Implement the Deletion Logic

In src/backend/src/controllers/statisticsController.ts, you will need to implement the deleteGraphCollection function. This function should:

A rough outline for this function might look like:

async deleteGraphCollection(req, res) {
    const { graphCollectionId } = req.params;
    // Logic to soft delete the graph collection
    // Example: await GraphCollection.update({ deleted: true }, { where: { id: graphCollectionId } });
}

3. Update the GraphCollection Model

In src/backend/src/models/GraphCollection.ts, ensure that your model supports the fields necessary for soft deletion, such as deleted or dateDeleted.

4. Write Unit Tests

In src/backend/src/tests/statistics.test.ts, add unit tests to verify that the endpoint behaves correctly. You should test:

Here’s a brief example of what a test might look like:

test('should soft delete a graph collection', async () => {
    const response = await request(app).delete('/statistics/1/delete');
    expect(response.status).toBe(200);
});

Conclusion

To tackle this issue, you will be adding a new endpoint to the statistics router, implementing the deletion logic in the controller, ensuring the model supports soft deletion, and writing comprehensive unit tests to validate the functionality. This approach will ensure that the new feature integrates seamlessly into the existing codebase while maintaining the integrity of the application.