Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: uploadDate를 date 형식에 포맷팅하여 order by 적용하도록 수정 #67

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/db/data/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const saveNoticeToDB = async (): Promise<void> => {
: college.departmentSubName;

if (noticeLists.pinnedNotice !== undefined) {
const pinnedNotiQuery = `SELECT link FROM ${major}고정 ORDER BY uploadDate DESC LIMIT 1;`;
const pinnedNotiQuery = `SELECT link FROM ${major}고정 ORDER BY STR_TO_DATE(uploadDate, '%Y-%m-%d') DESC LIMIT 1;`;
let pinnedNotiLink = '';
db.query(pinnedNotiQuery, async (err, res) => {
if (err) {
Expand All @@ -101,7 +101,7 @@ export const saveNoticeToDB = async (): Promise<void> => {
});
}

const normalNotiQuery = `SELECT link FROM ${major}일반 ORDER BY uploadDate DESC LIMIT 1;`;
const normalNotiQuery = `SELECT link FROM ${major}일반 ORDER BY STR_TO_DATE(uploadDate, '%Y-%m-%d') DESC LIMIT 1;`;
let normalNotiLink = '';
db.query(normalNotiQuery, async (err, res) => {
if (err) {
Expand Down Expand Up @@ -134,7 +134,7 @@ const saveSchoolNotice = async (
notices: string[],
mode: string,
): Promise<Promise<void>[]> => {
const query = `SELECT link FROM 학교${mode} ORDER BY uploadDate DESC LIMIT 1;`;
const query = `SELECT link FROM 학교${mode} ORDER BY STR_TO_DATE(uploadDate, '%Y-%m-%d') DESC LIMIT 1;`;
try {
const res = await new Promise<string>((resolve, reject) => {
db.query(query, (err, res) => {
Expand Down