Open giovabattelli opened 1 day ago
Please note, Sherpa may occasionally provide incomplete or inaccurate information. Always verify critical details and double-check suggested changes before implementation.
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.
src/backend/src/routes/statistics.routes.ts
: This file likely contains the routing logic for the statistics-related endpoints.src/backend/src/controllers/statistics.controller.ts
: This file should handle the business logic for statistics operations.src/backend/src/services/statistics.service.ts
: This file may contain service functions that interact with the database for statistics data.src/backend/src/tests/statistics.test.ts
: This file should contain unit tests related to the statistics endpoints.src/backend/src/routes/statistics.routes.ts
:
router.delete('/statistics/:graphCollectionId/delete', statisticsController.softDeleteGraphCollection);
src/backend/src/controllers/statistics.controller.ts
:
softDeleteGraphCollection
.graphCollectionId
from the request parameters and call the appropriate service method.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.' });
}
};
src/backend/src/services/statistics.service.ts
:
softDeleteGraphCollection
function. This function should interact with the database to mark the collection as deleted without removing it.export const softDeleteGraphCollection = async (graphCollectionId: string) => {
// Logic to update the database record to mark it as deleted
};
src/backend/src/tests/statistics.test.ts
:
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.');
});
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.
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