-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// it will import the compiled js file from dist directory | ||
const workerThreadFilePath = __dirname + '/process-ranking.js'; | ||
|
||
export default workerThreadFilePath; |
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,41 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { isMainThread, workerData } from 'worker_threads'; | ||
import { RankingModule } from '../ranking.module'; | ||
import { UpdateRankingService } from '../services'; | ||
|
||
async function run() { | ||
if (isMainThread) { | ||
throw new Error('This script should be run as a worker thread'); | ||
} | ||
const app = await NestFactory.createApplicationContext(RankingModule); | ||
const updateRankingService = app.get(UpdateRankingService); | ||
|
||
const { | ||
updateCompStatus, | ||
updateRanking, | ||
updatePossible, | ||
updateClubs, | ||
rankingDate, | ||
clubMembershipStartDate, | ||
clubMembershipEndDate, | ||
removeAllRanking, | ||
rankingSystemId, | ||
createNewPlayers, | ||
mappedData, | ||
} = workerData; | ||
|
||
await updateRankingService.processFileUpload(mappedData, { | ||
updateCompStatus, | ||
updateRanking, | ||
updatePossible, | ||
updateClubs, | ||
rankingDate, | ||
clubMembershipStartDate, | ||
clubMembershipEndDate, | ||
removeAllRanking, | ||
rankingSystemId, | ||
createNewPlayers, | ||
}); | ||
} | ||
|
||
run(); |