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

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.

Problem Summary

The issue requires creating an endpoint to soft delete a graph collection in the statistics router. The endpoint should be accessible via the route statistics/:graphCollectionId/delete and should include unit tests and Postman tests to verify functionality.

Relevant Files

Guidance for Code Changes

  1. src/backend/src/routes/statistics.routes.ts:

    • Add a new route for the delete operation. You can reference existing routes for syntax and structure.
    • Example:
      router.delete('/statistics/:graphCollectionId/delete', statisticsController.softDeleteGraphCollection);
  2. src/backend/src/controllers/statistics.controller.ts:

    • Implement a new controller method softDeleteGraphCollection.
    • This method should extract the graphCollectionId from the request parameters and call the appropriate service method.
    • Example:
      export const softDeleteGraphCollection = async (req, res) => {
      const { graphCollectionId } = req.params;
      try {
       await statisticsService.softDeleteGraphCollection(graphCollectionId);
       res.status(200).send({ message: 'Graph collection soft deleted successfully.' });
      } catch (error) {
       res.status(500).send({ error: 'Failed to delete graph collection.' });
      }
      };
  3. src/backend/src/services/statistics.service.ts:

    • Implement the softDeleteGraphCollection function. This function should interact with the database to mark the collection as deleted without removing it.
    • Example:
      export const softDeleteGraphCollection = async (graphCollectionId: string) => {
      // Logic to update the database record to mark it as deleted
      };
  4. src/backend/src/tests/statistics.test.ts:

    • Write unit tests for the new endpoint, ensuring it correctly marks a graph collection as deleted.
    • Use existing tests as a reference for structure and testing strategies.
    • Example:
      test('should soft delete a graph collection', async () => {
      const response = await request(app).delete('/statistics/123/delete');
      expect(response.status).toBe(200);
      expect(response.body.message).toBe('Graph collection soft deleted successfully.');
      });

Summary

To address this issue, you need to add a new endpoint in the statistics router to handle the soft deletion of graph collections. This involves creating a new route, implementing the corresponding controller and service logic, and ensuring comprehensive testing with unit tests and Postman. By following the existing patterns in the codebase, you can ensure consistency and reliability in your implementation.