Skip to content

Commit

Permalink
๐Ÿ”ง fix: commitTransaction ์ถ”๊ฐ€
Browse files Browse the repository at this point in the history
  • Loading branch information
uuuo3o authored Dec 1, 2024
1 parent 7d33746 commit b733123
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions BE/src/news/news.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ export class NewsService {
@Cron('*/1 * * * *')
async cronNewsData() {
const queryRunner = this.dataSource.createQueryRunner();
if (!queryRunner.isTransactionActive) {
await queryRunner.startTransaction('SERIALIZABLE');
}

try {
if (!queryRunner.isTransactionActive) {
await queryRunner.startTransaction('SERIALIZABLE');
}

await this.newsRepository.delete({ query: In(['์ฆ๊ถŒ', '์ฃผ์‹']) });
const stockNews = await this.getNewsDataByQuery('์ฃผ์‹');
const securityNews = await this.getNewsDataByQuery('์ฆ๊ถŒ');
Expand All @@ -74,6 +75,8 @@ export class NewsService {
updatedAt: new Date(),
},
);

await queryRunner.commitTransaction();
} catch (err) {
await queryRunner.rollbackTransaction();
throw new InternalServerErrorException(err);
Expand Down

0 comments on commit b733123

Please sign in to comment.