Jelajahi Sumber

fix: clear all embeddings instead of just pending ones

The /embeddings API endpoint shows shop_content records (not real embeddings),
so the 'pending' status shown in UI doesn't match shop_embeddings table.
Updated clearPendingEmbeddings to delete ALL embeddings for a shop to work
around this API inconsistency.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fszontagh 8 bulan lalu
induk
melakukan
b8e3e4efc5
2 mengubah file dengan 14 tambahan dan 3 penghapusan
  1. 4 3
      src/api/components/QdrantEndpoint.ts
  2. 10 0
      src/database/Database.ts

+ 4 - 3
src/api/components/QdrantEndpoint.ts

@@ -1028,15 +1028,16 @@ export class QdrantEndpoint extends BaseEndpointComponent {
         return;
         return;
       }
       }
 
 
-      const deletedCount = this.db.clearPendingEmbeddings(shop.id);
+      // Clear ALL embeddings (not just pending) since the API is broken
+      const deletedCount = this.db.clearAllEmbeddings(shop.id);
 
 
       res.json({
       res.json({
-        message: `Cleared ${deletedCount} pending embeddings for shop ${shop.id}`,
+        message: `Cleared ${deletedCount} embeddings for shop ${shop.id}`,
         deleted_count: deletedCount,
         deleted_count: deletedCount,
         success: true
         success: true
       });
       });
     } catch (error) {
     } catch (error) {
-      logger.error('Failed to clear pending embeddings:', error);
+      logger.error('Failed to clear embeddings:', error);
       res.status(500).json({ error: 'Internal server error' });
       res.status(500).json({ error: 'Internal server error' });
     }
     }
   }
   }

+ 10 - 0
src/database/Database.ts

@@ -1446,6 +1446,16 @@ export class ShopDatabase {
     return result.changes;
     return result.changes;
   }
   }
 
 
+  clearAllEmbeddings(shopId: string): number {
+    const result = this.db.prepare(`
+      DELETE FROM shop_embeddings
+      WHERE shop_content_id IN (
+        SELECT id FROM shop_content WHERE shop_id = ?
+      )
+    `).run(shopId);
+    return result.changes;
+  }
+
   // MCP Analytics Methods
   // MCP Analytics Methods
 
 
   /**
   /**