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

feat: Update기능, 폐업한 가게 DB에서 삭제 기능 추가 #75

Merged
merged 17 commits into from
Nov 8, 2023

Conversation

sphy1597
Copy link
Contributor

@sphy1597 sphy1597 commented Nov 7, 2023

시간이 부족할 것을 고려하여 성능은 고려하지 못한 상태에서 기능 구현만 한 상태입니다.

  1. 새로운 데이터를 api를 통해 읽어옴
  2. 폐업인 가게 중에 DB에 동일한 이름과 주소를 가진 가게가 있다면 DB에서 삭제
  3. 영업 중인 가게 데이터 업데이트
  • 새로운 데이터 읽어오기
  • 폐업한 가게 DB에서 삭제하기
  • 영업 중인 가게 데이터 업데이트

Copy link
Contributor

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

● hotplace session sql - hotplace - Visual Studio Code_01

좋습니다!

Comment on lines +77 to +79
schedule.scheduleJob("0 * * * * *", function () {
dbScheduler();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
schedule.scheduleJob("0 * * * * *", function () {
dbScheduler();
});
schedule.scheduleJob("0 * * * * *", dbScheduler);

함수를 인자 없이 그대로 실행한다면, 함수를 그대로 전달하면 가독성을 올릴 수 있어요!

Comment on lines +56 to +91
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,
},
},
);
}
Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 설정은 다른 운영체제에서 경로로 인한 오류가 발생할 수 있을 것 같아요. 어떤 용도인지 알려주실수 있을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어제 실행 오류를 해결하려고 하다보니 생긴 부분인것 같습니다

@scarf005 scarf005 merged commit 7b4a443 into wanted-7h:main Nov 8, 2023
@sphy1597 sphy1597 deleted the pipeline branch November 9, 2023 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants