From 0d45e7a00d342a5470fc1f4b9b8ac784e80a636a Mon Sep 17 00:00:00 2001 From: Javier Bullrich Date: Thu, 29 Feb 2024 12:52:38 +0100 Subject: [PATCH] moved log into approved ref query And added logging of queries which are not handled --- src/cron.ts | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/cron.ts b/src/cron.ts index 13f95c0..70a1dad 100644 --- a/src/cron.ts +++ b/src/cron.ts @@ -99,27 +99,27 @@ export const getAllRFCRemarks = async ( ); continue; } - } else { - logger.debug(`Reference query is not ongoing: ${JSON.stringify(refQuery)}`); - if (refQuery.approved) { - const [approvalDate] = refQuery.approved; - const blockDate = await getBlockDate(approvalDate, api); - if (startDate > blockDate) { - logger.info(`Confirmation of referenda #${index} happened before the previous check. Ignoring.`); - continue; - } - - logger.debug(`Fetching info from referenda ${index} from Subsquare`); - const rfc = await subsquareApi.fetchReferenda(index); - const confirmedBlock = rfc.onchainData.timeline.find(({ name }) => name === "Confirmed"); - if (confirmedBlock) { - completed.push({ - hash: rfc.onchainData.proposalHash, - executedHash: confirmedBlock.indexer.blockHash, - index, - }); - } + } else if (refQuery.approved) { + logger.debug(`Referendum has been approved: ${JSON.stringify(refQuery)}`); + const [approvalDate] = refQuery.approved; + const blockDate = await getBlockDate(approvalDate, api); + if (startDate > blockDate) { + logger.info(`Confirmation of referenda #${index} happened before the previous check. Ignoring.`); + continue; } + + logger.debug(`Fetching info from referenda ${index} from Subsquare`); + const rfc = await subsquareApi.fetchReferenda(index); + const confirmedBlock = rfc.onchainData.timeline.find(({ name }) => name === "Confirmed"); + if (confirmedBlock) { + completed.push({ + hash: rfc.onchainData.proposalHash, + executedHash: confirmedBlock.indexer.blockHash, + index, + }); + } + } else { + logger.debug(`Referendum state will not be handled ${JSON.stringify(refQuery)}`); } }