Răsfoiți Sursa

feat: add DELETE /api/qdrant/shops/:shopId/errors endpoint

Added missing endpoint to clear Qdrant errors for a specific shop.

Changes:
- Added DELETE /api/qdrant/shops/:shopId/errors endpoint
- Implemented clearShopQdrantErrors() handler method
- Supports both internal ID and custom ID for shop lookup
Fszontagh 8 luni în urmă
părinte
comite
78f4d18d6f
1 a modificat fișierele cu 50 adăugiri și 13 ștergeri
  1. 50 13
      src/api/components/QdrantEndpoint.ts

+ 50 - 13
src/api/components/QdrantEndpoint.ts

@@ -349,6 +349,30 @@ export class QdrantEndpoint extends BaseEndpointComponent {
         }
       ),
 
+      this.createEndpoint(
+        'DELETE',
+        '/api/qdrant/shops/:shopId/errors',
+        this.clearShopQdrantErrors.bind(this),
+        {
+          summary: 'Clear shop Qdrant errors',
+          description: 'Clear all Qdrant errors for a specific shop',
+          tags: ['Qdrant'],
+          requiresAuth: true,
+          parameters: [
+            {
+              name: 'shopId',
+              in: 'path',
+              type: 'string',
+              required: true,
+              description: 'Shop ID'
+            }
+          ],
+          responses: {
+            '200': { description: 'Errors cleared successfully' }
+          }
+        }
+      ),
+
       this.createEndpoint(
         'POST',
         '/api/qdrant/cleanup',
@@ -727,19 +751,6 @@ export class QdrantEndpoint extends BaseEndpointComponent {
     }
   }
 
-  private async clearShopQdrantErrors(req: Request, res: Response): Promise<void> {
-    try {
-      const { shopId } = req.params;
-
-      this.db.clearQdrantErrors(shopId);
-
-      res.json({ message: 'Errors cleared' });
-    } catch (error) {
-      logger.error('Failed to clear shop Qdrant errors:', error);
-      res.status(500).json({ error: 'Internal server error' });
-    }
-  }
-
   private async getSystemStats(req: Request, res: Response): Promise<void> {
     try {
       let totalCollections = 0;
@@ -916,6 +927,32 @@ export class QdrantEndpoint extends BaseEndpointComponent {
     }
   }
 
+  private async clearShopQdrantErrors(req: Request, res: Response): Promise<void> {
+    try {
+      const { shopId } = req.params;
+
+      // Get shop from database - try both internal ID and custom ID
+      let shop = this.db.getShopById(shopId);
+      if (!shop) {
+        shop = this.db.getShopByCustomId(shopId);
+      }
+      if (!shop) {
+        res.status(404).json({ error: 'Shop not found' });
+        return;
+      }
+
+      this.db.clearQdrantErrors(shop.id);
+
+      res.json({
+        message: `Cleared all Qdrant errors for shop ${shop.id}`,
+        success: true
+      });
+    } catch (error) {
+      logger.error('Failed to clear shop Qdrant errors:', error);
+      res.status(500).json({ error: 'Internal server error' });
+    }
+  }
+
   private async triggerCleanup(req: Request, res: Response): Promise<void> {
     try {
       // Trigger manual cleanup using the scheduler service