-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bugfix/editTags
- Loading branch information
Showing
8 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
services/apps/integration_data_worker/src/bin/process-data-for-tenant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { DB_CONFIG, SQS_CONFIG } from '@/conf' | ||
import IntegrationDataRepository from '@/repo/integrationData.repo' | ||
import { DbStore, getDbConnection } from '@crowd/database' | ||
import { getServiceLogger } from '@crowd/logging' | ||
import { IntegrationDataWorkerEmitter, getSqsClient } from '@crowd/sqs' | ||
import { IntegrationStreamDataState } from '@crowd/types' | ||
|
||
const log = getServiceLogger() | ||
|
||
const processArguments = process.argv.slice(2) | ||
|
||
if (processArguments.length !== 1) { | ||
log.error('Expected 1 argument: tenantId') | ||
process.exit(1) | ||
} | ||
|
||
const tenantId = processArguments[0] | ||
|
||
setImmediate(async () => { | ||
const sqsClient = getSqsClient(SQS_CONFIG()) | ||
const emitter = new IntegrationDataWorkerEmitter(sqsClient, log) | ||
await emitter.init() | ||
|
||
const dbConnection = getDbConnection(DB_CONFIG(), 1) | ||
const store = new DbStore(log, dbConnection) | ||
const repo = new IntegrationDataRepository(store, log) | ||
|
||
const dataIds = await repo.getDataForTenant(tenantId) | ||
|
||
for (const dataId of dataIds) { | ||
const info = await repo.getDataInfo(dataId) | ||
|
||
if (info) { | ||
if (info.state !== IntegrationStreamDataState.PENDING) { | ||
await repo.resetStream(dataId) | ||
} | ||
|
||
await emitter.triggerDataProcessing(info.tenantId, info.integrationType, dataId) | ||
} else { | ||
log.error({ dataId }, 'Data stream not found!') | ||
process.exit(1) | ||
} | ||
} | ||
}) |
42 changes: 42 additions & 0 deletions
42
services/apps/integration_data_worker/src/bin/process-data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { DB_CONFIG, SQS_CONFIG } from '@/conf' | ||
import IntegrationDataRepository from '@/repo/integrationData.repo' | ||
import { DbStore, getDbConnection } from '@crowd/database' | ||
import { getServiceLogger } from '@crowd/logging' | ||
import { IntegrationDataWorkerEmitter, getSqsClient } from '@crowd/sqs' | ||
import { IntegrationStreamDataState } from '@crowd/types' | ||
|
||
const log = getServiceLogger() | ||
|
||
const processArguments = process.argv.slice(2) | ||
|
||
if (processArguments.length !== 1) { | ||
log.error('Expected 1 argument: dataId') | ||
process.exit(1) | ||
} | ||
|
||
const dataIds = processArguments[0].split(',') | ||
|
||
setImmediate(async () => { | ||
const sqsClient = getSqsClient(SQS_CONFIG()) | ||
const emitter = new IntegrationDataWorkerEmitter(sqsClient, log) | ||
await emitter.init() | ||
|
||
const dbConnection = getDbConnection(DB_CONFIG(), 1) | ||
const store = new DbStore(log, dbConnection) | ||
const repo = new IntegrationDataRepository(store, log) | ||
|
||
for (const dataId of dataIds) { | ||
const info = await repo.getDataInfo(dataId) | ||
|
||
if (info) { | ||
if (info.state !== IntegrationStreamDataState.PENDING) { | ||
await repo.resetStream(dataId) | ||
} | ||
|
||
await emitter.triggerDataProcessing(info.tenantId, info.integrationType, dataId) | ||
} else { | ||
log.error({ dataId }, 'Data stream not found!') | ||
process.exit(1) | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters