From e7a7b41531ae26876fffcf707676c5b0b2edd7e4 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Wed, 13 Sep 2023 18:39:36 -0300 Subject: [PATCH] fix(all): Fix search on others bots than boot. --- packages/kb.gbapp/services/KBService.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/kb.gbapp/services/KBService.ts b/packages/kb.gbapp/services/KBService.ts index f685824e..a046796e 100644 --- a/packages/kb.gbapp/services/KBService.ts +++ b/packages/kb.gbapp/services/KBService.ts @@ -585,16 +585,6 @@ export class KBService implements IGBKBService { } }); - await GuaribasQuestion.destroy({ - where: { instanceId: min.instance.instanceId } - }); - await GuaribasAnswer.destroy({ - where: { instanceId: min.instance.instanceId } - }); - await GuaribasSubject.destroy({ - where: { instanceId: min.instance.instanceId} - }); - const answersCreated = await GuaribasAnswer.bulkCreate(answers); let i = 0; @@ -677,6 +667,20 @@ export class KBService implements IGBKBService { const subjectFile = urlJoin(localPath, 'subjects.json'); const menuFile = urlJoin(localPath, 'menu.xlsx'); + // Bot KB store clean up. + + await GuaribasQuestion.destroy({ + where: { instanceId: min.instance.instanceId } + }); + await GuaribasAnswer.destroy({ + where: { instanceId: min.instance.instanceId } + }); + await GuaribasSubject.destroy({ + where: { instanceId: min.instance.instanceId} + }); + + // Imports menu.xlsx if any. + if (Fs.existsSync(subjectFile) || Fs.existsSync(menuFile)) { await this.importSubjectFile(packageStorage.packageId, subjectFile, menuFile, instance); }