From a55087057265cdb7cd02539c3ac1410a4505e397 Mon Sep 17 00:00:00 2001 From: vhcsilva Date: Thu, 7 Nov 2024 10:26:22 -0300 Subject: [PATCH 1/3] dot not destroy deliverables --- src/actions/get-bounty-canceled-event.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/actions/get-bounty-canceled-event.ts b/src/actions/get-bounty-canceled-event.ts index 24652f1d..6714d884 100644 --- a/src/actions/get-bounty-canceled-event.ts +++ b/src/actions/get-bounty-canceled-event.ts @@ -13,6 +13,7 @@ import {updateBountiesHeader} from "src/modules/handle-header-information"; import {Push} from "../services/analytics/push"; import {AnalyticEventName} from "../services/analytics/types/events"; import updateSeoCardBounty from "src/modules/handle-seo-card"; +import { Op } from "sequelize"; export const name = "getBountyCanceledEvents"; export const schedule = "*/11 * * * *"; @@ -34,10 +35,11 @@ export async function action(block: DecodedLog, query?: EventsQuery): Promise 0) - for (const dr of dbBounty?.deliverables) { - await dr.destroy() - } + // if(isHardCancel) { + // if(dbBounty?.deliverables.length > 0) + // for (const dr of dbBounty?.deliverables) { + // await dr.destroy() + // } - } + // } dbBounty.state = `canceled`; From 8ac27ea6abb8fd3057057afde49a826ef4f51a27 Mon Sep 17 00:00:00 2001 From: vhcsilva Date: Thu, 7 Nov 2024 10:54:30 -0300 Subject: [PATCH 2/3] destroy comments and deliverable --- src/actions/get-bounty-canceled-event.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/actions/get-bounty-canceled-event.ts b/src/actions/get-bounty-canceled-event.ts index 6714d884..f5b634f1 100644 --- a/src/actions/get-bounty-canceled-event.ts +++ b/src/actions/get-bounty-canceled-event.ts @@ -39,7 +39,7 @@ export async function action(block: DecodedLog, query?: EventsQuery): Promise 0) - // for (const dr of dbBounty?.deliverables) { - // await dr.destroy() - // } - - // } + if(isHardCancel) { + if(dbBounty?.deliverables.length > 0) + for (const dr of dbBounty?.deliverables) { + for (const comment of dr.comments) + await comment.destroy(); + await dr.destroy(); + } + } dbBounty.state = `canceled`; From 10bdf7422c5869c5eb7254360f580820d2137d79 Mon Sep 17 00:00:00 2001 From: vhcsilva Date: Thu, 7 Nov 2024 11:03:30 -0300 Subject: [PATCH 3/3] add verifications --- src/actions/get-bounty-canceled-event.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/actions/get-bounty-canceled-event.ts b/src/actions/get-bounty-canceled-event.ts index f5b634f1..64f11d43 100644 --- a/src/actions/get-bounty-canceled-event.ts +++ b/src/actions/get-bounty-canceled-event.ts @@ -54,10 +54,13 @@ export async function action(block: DecodedLog, query?: EventsQuery): Promise 0) + if(dbBounty?.deliverables?.length > 0) for (const dr of dbBounty?.deliverables) { - for (const comment of dr.comments) - await comment.destroy(); + if (dr.comments?.length > 0) { + for (const comment of dr.comments) + await comment.destroy(); + } + await dr.destroy(); } }