From 740bdb2c75a7ee2d62276aef0f9a805267eaf16e Mon Sep 17 00:00:00 2001 From: Lee sang Yeop Date: Thu, 11 Jan 2024 14:54:03 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix(noticeHandler=20convertAllNoticeToNorma?= =?UTF-8?q?lNotice):=20=EB=A7=8C=EC=95=BD=20connection=20=EC=9D=B4=20?= =?UTF-8?q?=EC=9E=88=EC=9C=BC=EB=A9=B4=20=ED=8A=B8=EB=9E=9C=EC=9E=AD?= =?UTF-8?q?=EC=85=98=EC=9C=BC=EB=A1=9C=20=EC=B2=98=EB=A6=AC=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db/data/noticeHandler.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/db/data/noticeHandler.ts b/src/db/data/noticeHandler.ts index f901e14..d79134a 100644 --- a/src/db/data/noticeHandler.ts +++ b/src/db/data/noticeHandler.ts @@ -62,11 +62,13 @@ const saveMajorNotice = async ( const convertAllNoticeToNormalNotice = async ( tableName: string, + connection?: PoolConnection, ): Promise => { const query = `UPDATE ${tableName} SET rep_yn = false;`; try { - await db.execute(query); + if (connection) await connection.execute(query); + else await db.execute(query); console.log('모든 공지를 일반 공지로 변경'); } catch (error) { notificationToSlack(error.message + '\n모든 공지를 일반 공지로 변경 실패'); @@ -89,7 +91,7 @@ const convertSpecificNoticeToPinnedNotice = async ( export const saveMajorNoticeToDB = async ( connection?: PoolConnection, ): Promise => { - await convertAllNoticeToNormalNotice('major_notices'); + await convertAllNoticeToNormalNotice('major_notices', connection); const query = 'SELECT * FROM departments;'; const colleges = await selectQuery(query, connection); From 07997f8d18d5a483362c282a9a526b039b1ae228 Mon Sep 17 00:00:00 2001 From: Lee sang Yeop Date: Thu, 11 Jan 2024 14:59:03 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix(notice/service):=20=ED=95=99=EA=B3=BC?= =?UTF-8?q?=20=EA=B3=B5=EC=A7=80=EC=82=AC=ED=95=AD=EC=9D=84=20DB=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EA=BA=BC=EB=82=BC=20=EB=95=8C=20=EB=82=A0=EC=A7=9C?= =?UTF-8?q?=20=EC=88=9C=EC=84=9C=EB=8C=80=EB=A1=9C=20=EC=A0=95=EB=A0=AC?= =?UTF-8?q?=ED=95=B4=EC=84=9C=20=EA=BA=BC=EB=82=B4=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/notice/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apis/notice/service.ts b/src/apis/notice/service.ts index efd7539..f4e9eca 100644 --- a/src/apis/notice/service.ts +++ b/src/apis/notice/service.ts @@ -43,7 +43,7 @@ const updateNotice = (notices: Notices[]) => { export const getNotices = async (department: string): Promise => { const majorId = await getDepartmentIdByMajor(department); - const query = `SELECT * FROM major_notices WHERE department_id = ${majorId};`; + const query = `SELECT * FROM major_notices WHERE department_id = ${majorId} ORDER BY STR_TO_DATE(upload_date, '%Y-%m-%d') DESC;`; const major_notices = await selectQuery(query); const notices: SeparateNoti = {