-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from Boost-Coder/feature/Batch-#92
[#92] 매 00:00 분에 사용자 정보를 업데이트 하는 기능 구현
- Loading branch information
Showing
12 changed files
with
160 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { BatchService } from './batch.service'; | ||
import { UserModule } from '../user/user.module'; | ||
import { StatModule } from '../stat/stat.module'; | ||
|
||
@Module({ | ||
imports: [UserModule, StatModule], | ||
providers: [BatchService], | ||
}) | ||
export class BatchModule {} |
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,32 @@ | ||
import { Injectable, Logger } from '@nestjs/common'; | ||
import { Cron } from '@nestjs/schedule'; | ||
import { UserService } from '../user/user.service'; | ||
import { AlgorithmService } from '../stat/service/algorithm.service'; | ||
import { GithubService } from '../stat/service/github.service'; | ||
import { TotalService } from '../stat/service/total.service'; | ||
import { IsolationLevel, Transactional } from 'typeorm-transactional'; | ||
|
||
@Injectable() | ||
export class BatchService { | ||
private readonly logger = new Logger(BatchService.name); | ||
constructor( | ||
private userService: UserService, | ||
private algorithmService: AlgorithmService, | ||
private githubService: GithubService, | ||
private totalService: TotalService, | ||
) {} | ||
@Cron('0 0 * * * *') | ||
@Transactional({ | ||
isolationLevel: IsolationLevel.READ_COMMITTED, | ||
}) | ||
async updateAllUserStat() { | ||
this.logger.log(`모든 유저의 역량 업데이트 시작`); | ||
const users = await this.userService.getUsers(); | ||
for (const user of users) { | ||
await this.algorithmService.updateAlgorithm(user.userId); | ||
await this.githubService.updateGithub(user.userId); | ||
await this.totalService.updateTotal(user.userId); | ||
} | ||
this.logger.log(`모든 유저의 역량 업데이트 완료`); | ||
} | ||
} |
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