From 4e37add65b7dcb2968d31c9fcab58321a37c75df Mon Sep 17 00:00:00 2001 From: esurface Date: Thu, 1 Aug 2024 07:45:36 -0400 Subject: [PATCH] If set, only reset the reporting state sequence for groups in T_ONLY_PROCESS_THESE_GROUPS --- server/src/reporting/clear-reporting-cache.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/src/reporting/clear-reporting-cache.js b/server/src/reporting/clear-reporting-cache.js index 0d529440b..ee5636e13 100644 --- a/server/src/reporting/clear-reporting-cache.js +++ b/server/src/reporting/clear-reporting-cache.js @@ -34,13 +34,25 @@ async function clearReportingCache() { } groupNames = groupNames.filter(groupName => onlyProcessTheseGroups.includes(groupName)); + // run the module clearReportingCache hooks await tangyModules.hook('clearReportingCache', { groupNames }) + // update worker state + debugger; console.log('Resetting reporting worker state...') const contents = await readFile(REPORTING_WORKER_STATE, 'utf-8') const state = JSON.parse(contents) const newState = Object.assign({}, state, { - databases: state.databases.map(({name, sequence}) => { return {name, sequence: 0}}) + databases: state.databases.map( + ({name, sequence}) => + { + if (groupNames.length == 0 || groupNames.includes(name)) { + return {name, sequence: 0} + } else { + return {name, sequence} + } + } + ) }) await writeFile(REPORTING_WORKER_STATE, JSON.stringify(newState), 'utf-8') await unlink(REPORTING_WORKER_PAUSE)