Skip to content

Commit

Permalink
Merge pull request #173 from GDSC-PKNU-Official/fix/#172
Browse files Browse the repository at this point in the history
  • Loading branch information
pp449 authored Jan 12, 2024
2 parents 539f08e + 07997f8 commit 91e94aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/apis/notice/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const updateNotice = (notices: Notices[]) => {

export const getNotices = async (department: string): Promise<SeparateNoti> => {
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<Notices[]>(query);

const notices: SeparateNoti = {
Expand Down
6 changes: 4 additions & 2 deletions src/db/data/noticeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ const saveMajorNotice = async (

const convertAllNoticeToNormalNotice = async (
tableName: string,
connection?: PoolConnection,
): Promise<void> => {
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모든 공지를 일반 공지로 변경 실패');
Expand All @@ -89,7 +91,7 @@ const convertSpecificNoticeToPinnedNotice = async (
export const saveMajorNoticeToDB = async (
connection?: PoolConnection,
): Promise<PushNoti> => {
await convertAllNoticeToNormalNotice('major_notices');
await convertAllNoticeToNormalNotice('major_notices', connection);
const query = 'SELECT * FROM departments;';
const colleges = await selectQuery<College[]>(query, connection);

Expand Down

0 comments on commit 91e94aa

Please sign in to comment.