-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Update기능, 폐업한 가게 DB에서 삭제 기능 추가 #75
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schedule.scheduleJob("0 * * * * *", function () { | ||
dbScheduler(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schedule.scheduleJob("0 * * * * *", function () { | |
dbScheduler(); | |
}); | |
schedule.scheduleJob("0 * * * * *", dbScheduler); |
함수를 인자 없이 그대로 실행한다면, 함수를 그대로 전달하면 가독성을 올릴 수 있어요!
for (let i in restaurants) { | ||
// 폐업한 가게 중에서 DB에 데이터가 있다면 삭제 | ||
if (restaurants[i].BSN_STATE_NM == "폐업") { | ||
const closed = await db.Restaurant.findOne({ | ||
where: { | ||
restaurant_name: restaurants[i].BIZPLC_NM, | ||
adress: restaurants[i].REFINE_LOTNO_ADDR, | ||
}, | ||
}); | ||
// 삭제 로직 | ||
if (closed !== null) { | ||
db.Restaurant.destroy({ | ||
where: { | ||
restaurant_name: restaurants[i].BIZPLC_NM, | ||
adress: restaurants[i].REFINE_LOTNO_ADDR, | ||
}, | ||
}); | ||
} | ||
} else { | ||
// 영업 중인 가게 정보 업데이트 | ||
db.Restaurant.update( | ||
{ | ||
restaurant_name: restaurants[i].BIZPLC_NM, | ||
restaurant_type: restaurants[i].SANITTN_BIZCOND_NM, | ||
adress: restaurants[i].REFINE_LOTNO_ADDR, // 도로명 주소가 없는 식당이 존재 함 | ||
lat: Number(restaurants[i].REFINE_WGS84_LAT), | ||
lon: Number(restaurants[i].REFINE_WGS84_LOGT), | ||
}, | ||
{ | ||
where: { | ||
restaurant_name: restaurants[i].BIZPLC_NM, | ||
adress: restaurants[i].REFINE_LOTNO_ADDR, | ||
}, | ||
}, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for...of 문법을 사용해 가독성을 올리고 실수를 줄일 수 있을 것 같아요!
@@ -6,5 +6,6 @@ | |||
"editor.formatOnSave": true, | |||
"editor.formatOnPaste": true, | |||
"editor.defaultFormatter": "esbenp.prettier-vscode" | |||
} | |||
}, | |||
"typescript.tsdk": "node_modules\\typescript\\lib" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 설정은 다른 운영체제에서 경로로 인한 오류가 발생할 수 있을 것 같아요. 어떤 용도인지 알려주실수 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어제 실행 오류를 해결하려고 하다보니 생긴 부분인것 같습니다
시간이 부족할 것을 고려하여 성능은 고려하지 못한 상태에서 기능 구현만 한 상태입니다.