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

[REFACTOR] func와 roomStartPOST Insert 함수 호출에 배열 길이 조건 추가 #453

Merged
merged 1 commit into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions functions/api/routes/room/roomStartPOST.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ module.exports = async (req, res) => {
insertTimelines.push(`('${entry.userId}', '${entry.roomId}', false, 1)`);
}

// 참여자들의 1일차 record 생성
await recordDB.insertRecords(client, insertRecords);
if (insertRecords.length > 0) {
// 참여자들의 1일차 record 생성
await recordDB.insertRecords(client, insertRecords);
}

// 참여자들의 1일차 Life Timeline 생성
await lifeTimelineDB.addFillTimelines(client, insertTimelines);
if (insertTimelines.length > 0) {
// 참여자들의 1일차 Life Timeline 생성
await lifeTimelineDB.addFillTimelines(client, insertTimelines);
}

const { title, body, isService, category } = alarmMessage.ROOM_NEW(room.roomName);

Expand Down
12 changes: 9 additions & 3 deletions functions/scheduler/funcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ const checkLife = async () => {

fillLifeRoomIds = Array.from(fillLifeRoomIds);

await recordDB.insertRecords(client, insertRecords); // record 추가!
await lifeTimelineDB.addFillTimelines(client, insertTimelines); // lifeTimeline 추가!
await roomDB.fillLifeByRoomIds(client, fillLifeRoomIds); // 생명 충전
if (insertRecords.length > 0) {
await recordDB.insertRecords(client, insertRecords); // record 추가!
}
if (insertTimelines.length > 0) {
await lifeTimelineDB.addFillTimelines(client, insertTimelines); // lifeTimeline 추가!
}
if (fillLifeRoomIds.length > 0) {
await roomDB.fillLifeByRoomIds(client, fillLifeRoomIds); // 생명 충전
}

const slackMessage = `폭파된 방 목록: ${failRoomIds} \n 생명 충전 방 목록: ${fillLifeRoomIds} \n 살아남은 방 목록: ${survivedRoomIds}`;
slackAPI.sendMessageToSlack(slackMessage, slackAPI.DEV_WEB_HOOK_ERROR_MONITORING);
Expand Down