Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanni Troisi committed Dec 20, 2024
1 parent 2beddf6 commit 7c22b07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions routes/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ router.post('/kb/reindex', async (req, res) => {
if (!kb) {
winston.warn("(webhook) Kb content not found with id ", content_id);
// Assuming the content has been deleted. The scheduler should be stopped and deleted.
let aiReindexService = new AiReindexService(content_id);
let deleteResponse = await aiReindexService.delete().catch((err) => {
let aiReindexService = new AiReindexService();
let deleteResponse = await aiReindexService.delete(content_id).catch((err) => {
winston.error("(webhook) Error deleting scheduler ", err);
winston.error("(webhook) Error deleting scheduler " + err);
return res.status(500).send({ success: false, message: "Content no longer exists. Error deleting scheduler", error: err })
});
winston.debug("(webhook) delete response: ", deleteResponse);
Expand Down
3 changes: 3 additions & 0 deletions services/aiReindexService.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ class AiReindexService {

return new Promise( async (resolve, reject) => {

console.log("search and delete scheduler for content ", content_id)
let scheduler = await this.findScheduler(content_id).catch((err) => {
reject(err);
})

console.log("scheduler: ", scheduler)
winston.verbose("(AiReindexService) delete() - scheduler: ", scheduler);

if (!scheduler) {
Expand Down Expand Up @@ -73,6 +75,7 @@ class AiReindexService {
}
}).then((response) => {

console.log("schedulers found: ", response.data.data)
let scheduler = response.data.data.find(s => s.processDefinitionName === "auto-reindex-" + id);
if (!scheduler) {
resolve(null);
Expand Down

0 comments on commit 7c22b07

Please sign in to comment.