From b7331236d11b918ea0328645ae7c1dcb53873c41 Mon Sep 17 00:00:00 2001 From: JIN <80706216+uuuo3o@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:24:31 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix:=20commitTransaction=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BE/src/news/news.service.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BE/src/news/news.service.ts b/BE/src/news/news.service.ts index 01989b4..2689e23 100644 --- a/BE/src/news/news.service.ts +++ b/BE/src/news/news.service.ts @@ -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('증권'); @@ -74,6 +75,8 @@ export class NewsService { updatedAt: new Date(), }, ); + + await queryRunner.commitTransaction(); } catch (err) { await queryRunner.rollbackTransaction(); throw new InternalServerErrorException(err);