|
|
@@ -563,6 +563,30 @@ export class QdrantEndpoint extends BaseEndpointComponent {
|
|
|
'200': { description: 'Errors cleared' }
|
|
|
}
|
|
|
}
|
|
|
+ ),
|
|
|
+
|
|
|
+ this.createEndpoint(
|
|
|
+ 'DELETE',
|
|
|
+ '/api/shops/:shopId/qdrant/pending-embeddings',
|
|
|
+ this.clearPendingEmbeddings.bind(this),
|
|
|
+ {
|
|
|
+ summary: 'Clear pending embeddings',
|
|
|
+ description: 'Clear all pending embeddings for a shop',
|
|
|
+ tags: ['Qdrant'],
|
|
|
+ requiresAuth: true,
|
|
|
+ parameters: [
|
|
|
+ {
|
|
|
+ name: 'shopId',
|
|
|
+ in: 'path',
|
|
|
+ type: 'string',
|
|
|
+ required: true,
|
|
|
+ description: 'Shop ID'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ responses: {
|
|
|
+ '200': { description: 'Pending embeddings cleared' }
|
|
|
+ }
|
|
|
+ }
|
|
|
)
|
|
|
];
|
|
|
}
|
|
|
@@ -990,6 +1014,33 @@ export class QdrantEndpoint extends BaseEndpointComponent {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private async clearPendingEmbeddings(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;
|
|
|
+ }
|
|
|
+
|
|
|
+ const deletedCount = this.db.clearPendingEmbeddings(shop.id);
|
|
|
+
|
|
|
+ res.json({
|
|
|
+ message: `Cleared ${deletedCount} pending embeddings for shop ${shop.id}`,
|
|
|
+ deleted_count: deletedCount,
|
|
|
+ success: true
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ logger.error('Failed to clear pending embeddings:', 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
|