Skip to content

Commit

Permalink
Allow solo runs with appIds and partnerIds
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Oct 10, 2023
1 parent cb5179b commit de645a6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions config.sample.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"couchDbFullpath": "http://admin:admin@localhost:5984",
"httpPort": "8000",
"soloAppId": null,
"soloPluginId": null,
"soloAppIds": null,
"soloPartnerIds": null,
"timeoutOverrideMins": null,
"cacheLookbackMonths": null
}
14 changes: 11 additions & 3 deletions src/cacheEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,21 @@ export async function cacheEngine(): Promise<void> {
const rawApps = await reportsApps.find(query)
const apps = asApps(rawApps.docs)
for (const app of apps) {
if (config.soloAppId != null && config.soloAppId !== app.appId) continue

if (
config.soloAppIds != null &&
config.soloAppIds.includes(app.appId) === false
) {
continue
}
const partnerIds = Object.keys(app.partnerIds)

for (const partnerId of partnerIds) {
if (config.soloPartnerId != null && config.soloPartnerId !== partnerId)
if (
config.soloPartnerIds != null &&
config.soloPartnerIds.includes(partnerId) === false
) {
continue
}
for (const timePeriod of TIME_PERIODS) {
const data = await getAnalytic(
start,
Expand Down
13 changes: 11 additions & 2 deletions src/queryEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,24 @@ export async function queryEngine(): Promise<void> {
let remainingPartners: String[] = []
// loop over every app
for (const app of apps) {
if (config.soloAppId != null && config.soloAppId !== app.appId) continue
if (
config.soloAppIds != null &&
config.soloAppIds.includes(app.appId) === false
) {
continue
}
let partnerStatus: string[] = []
// loop over every pluginId that app uses
remainingPartners = Object.keys(app.partnerIds)
for (const partnerId in app.partnerIds) {
const pluginId = app.partnerIds[partnerId].pluginId ?? partnerId

if (config.soloPartnerId != null && config.soloPartnerId !== partnerId)
if (
config.soloPartnerIds != null &&
config.soloPartnerIds.includes(partnerId) === false
) {
continue
}
remainingPartners.push(partnerId)
promiseArray.push(
runPlugin(app, partnerId, pluginId, dbProgress).finally(() => {
Expand Down

0 comments on commit de645a6

Please sign in to comment.