Skip to content

Commit

Permalink
If set, only reset the reporting state sequence for groups in T_ONLY_…
Browse files Browse the repository at this point in the history
…PROCESS_THESE_GROUPS
  • Loading branch information
esurface committed Aug 1, 2024
1 parent 3e731aa commit 4e37add
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion server/src/reporting/clear-reporting-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4e37add

Please sign in to comment.