Skip to content

Commit

Permalink
When has a list of one or more groups, running will only process the …
Browse files Browse the repository at this point in the history
…groups in the list
  • Loading branch information
esurface committed Jul 25, 2024
1 parent 3858864 commit 05f7974
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ __Fixes__
- Client Search Service: exclude archived cases from recent activity
- Media library cannot upload photos [#3583](https://github.com/Tangerine-Community/Tangerine/issues/3583)
- User Profile Import: The process of importing an existing device user now allows for retries and an asynchronous process to download existing records. This fixes an issue cause by timeouts when trying to import a user with a large number of records. [#3696](https://github.com/Tangerine-Community/Tangerine/issues/3696)
- When `T_ONLY_PROCESS_THESE_GROUPS` has a list of one or more groups, running `reporting-cache-clear` will only process the groups in the list

__Tangerine Teach__

Expand Down
10 changes: 6 additions & 4 deletions config.defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ T_MYSQL_CONTAINER_NAME="mysql"
T_MYSQL_USER="admin"
T_MYSQL_PASSWORD="password"
T_MYSQL_PHPMYADMIN="FALSE"
# Enter "true" if using a mysql container instead of an external database service such as AWS RDS. This will launch a mysql container.
T_USE_MYSQL_CONTAINER=""

#
# Optional
Expand Down Expand Up @@ -62,12 +64,12 @@ T_REPORTING_DELAY="300000"
# Number of change docs from the Couchdb changes feed queried by reporting-worker (i.e. use as the limit parameter)
T_LIMIT_NUMBER_OF_CHANGES=200

# Limit processing to certain group dbs.
# Limit processing to certain group dbs. Cache clear and batching reporting outputs will only run on the groups specified below.
# If empty, all groups will be processed.
# The value of the paramter is an array of group names. For example:
# T_ONLY_PROCESS_THESE_GROUPS="['group-1','group-2']"
T_ONLY_PROCESS_THESE_GROUPS=""

# Enter "true" if using a mysql container instead of an external database service such as AWS RDS. This will launch a mysql container.
T_USE_MYSQL_CONTAINER=""

# When CSV is generated, this determines how many form responses are held in memory during a batch. The higher the number the more memory this process will take but the faster it will complete.
T_CSV_BATCH_SIZE=50

Expand Down
12 changes: 10 additions & 2 deletions server/src/reporting/clear-reporting-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ async function clearReportingCache() {
if (reportingWorkerRunning) await sleep(1*1000)
}
console.log('Clearing reporting caches...')
const groupNames = await groupsList()
let groupNames = await groupsList()

let onlyProcessTheseGroups = []
if (process.env.T_ONLY_PROCESS_THESE_GROUPS && process.env.T_ONLY_PROCESS_THESE_GROUPS !== '') {
onlyProcessTheseGroups = process.env.T_ONLY_PROCESS_THESE_GROUPS
? JSON.parse(process.env.T_ONLY_PROCESS_THESE_GROUPS.replace(/\'/g, `"`))
: []
}
groupNames = groupNames.filter(groupName => onlyProcessTheseGroups.includes(groupName));

await tangyModules.hook('clearReportingCache', { groupNames })
// update worker state
console.log('Resetting reporting worker state...')
Expand All @@ -33,7 +42,6 @@ async function clearReportingCache() {
const newState = Object.assign({}, state, {
databases: state.databases.map(({name, sequence}) => { return {name, sequence: 0}})
})
console.log("newState: " + JSON.stringify(newState))
await writeFile(REPORTING_WORKER_STATE, JSON.stringify(newState), 'utf-8')
await unlink(REPORTING_WORKER_PAUSE)
console.log('Done!')
Expand Down

0 comments on commit 05f7974

Please sign in to comment.