-
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.
Missing indexes, script improvements, fixes (#1500)
- Loading branch information
Uros Marolt
authored
Sep 15, 2023
1 parent
aa5cb7e
commit f09901f
Showing
8 changed files
with
121 additions
and
43 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
1 change: 1 addition & 0 deletions
1
backend/src/database/migrations/U1694760454__segment-activity-channels-missing-index.sql
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 @@ | ||
drop index if exists "ix_segmentActivityChannels_segmentId_platform"; |
1 change: 1 addition & 0 deletions
1
backend/src/database/migrations/V1694760454__segment-activity-channels-missing-index.sql
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 @@ | ||
create index if not exists "ix_segmentActivityChannels_segmentId_platform" on "segmentActivityChannels" ("segmentId", platform); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { DB_CONFIG, REDIS_CONFIG, SQS_CONFIG } from '@/conf' | ||
import DataSinkRepository from '@/repo/dataSink.repo' | ||
import DataSinkService from '@/service/dataSink.service' | ||
import { DbStore, getDbConnection } from '@crowd/database' | ||
import { getServiceLogger } from '@crowd/logging' | ||
import { getRedisClient } from '@crowd/redis' | ||
import { NodejsWorkerEmitter, SearchSyncWorkerEmitter, getSqsClient } from '@crowd/sqs' | ||
|
||
const log = getServiceLogger() | ||
|
||
const processArguments = process.argv.slice(2) | ||
|
||
if (processArguments.length !== 1) { | ||
log.error('Expected 1 argument: resultIds') | ||
process.exit(1) | ||
} | ||
|
||
const resultIds = processArguments[0].split(',') | ||
|
||
setImmediate(async () => { | ||
const sqsClient = getSqsClient(SQS_CONFIG()) | ||
const redisClient = await getRedisClient(REDIS_CONFIG()) | ||
|
||
const nodejsWorkerEmitter = new NodejsWorkerEmitter(sqsClient, log) | ||
const searchSyncWorkerEmitter = new SearchSyncWorkerEmitter(sqsClient, log) | ||
|
||
const dbConnection = await getDbConnection(DB_CONFIG()) | ||
const store = new DbStore(log, dbConnection) | ||
|
||
const service = new DataSinkService( | ||
store, | ||
nodejsWorkerEmitter, | ||
searchSyncWorkerEmitter, | ||
redisClient, | ||
log, | ||
) | ||
|
||
const repo = new DataSinkRepository(store, log) | ||
for (const resultId of resultIds) { | ||
const result = await repo.getResultInfo(resultId) | ||
if (!result) { | ||
log.error(`Result ${resultId} not found!`) | ||
continue | ||
} else { | ||
await repo.resetResults([resultId]) | ||
|
||
await service.processResult(resultId) | ||
} | ||
} | ||
|
||
process.exit(0) | ||
}) |
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