diff --git a/functions/api/routes/room/roomDetailGET.js b/functions/api/routes/room/roomDetailGET.js index ed471b0..e62a7b1 100644 --- a/functions/api/routes/room/roomDetailGET.js +++ b/functions/api/routes/room/roomDetailGET.js @@ -34,7 +34,7 @@ module.exports = async (req, res) => { const now = dayjs().add(9, 'hour'); const today = dayjs(now.format('YYYY-MM-DD')); const leftDay = endDate.diff(today, 'day'); - const day = today.diff(startDate, 'day') + 1; + const day = today.diff(startDate, 'day'); console.log(today); // @error 1. 존재하지 않는 습관방인 경우 if (!room) { diff --git a/functions/scheduler/funcs.js b/functions/scheduler/funcs.js index c7067ce..cad7c2b 100644 --- a/functions/scheduler/funcs.js +++ b/functions/scheduler/funcs.js @@ -2,13 +2,14 @@ const db = require('../db/db'); const { roomDB, recordDB } = require('../db'); const _ = require('lodash'); const dayjs = require('dayjs'); -const slackAPI = require('../../../middlewares/slackAPI'); +const slackAPI = require('../middlewares/slackAPI'); const checkLife = async() => { let client; try { client = await db.connect(); const failRecords = await roomDB.getFailRecords(client); // 습관방별 [실패한 record 개수(failCount)] 불러오기 + console.log(failRecords); const roomGroupByFailCount = _.groupBy(failRecords, "failCount"); // failCount별 roomId 묶어주기 (ex. [{"failCount": 1, "roomId": [1,2,3]}, {"failCount":2, "roomId": [4,5,6]}]) const failCountList = [... new Set(failRecords.map((o) => Number(o.failCount)))]; // failCount 뭐뭐있는지~ (ex. [1,2,3]) const roomIdsByFailCount = {'1':[], '2':[], '3':[]}; @@ -40,12 +41,13 @@ const checkLife = async() => { const insertEntries = successEntries.map((o) => { // 추가해줄 record들의 속성들 빚어주기 const startDate = dayjs(o.startAt); - const day = dayjs(today).diff(startDate, 'day') + 1; + const day = dayjs(today).diff(startDate, 'day'); const queryParameter = "(" + o.entryId + ",'" + now.format('YYYY-MM-DD') + "'," + day + ")"; return queryParameter; }); - const resultRecords = await recordDB.insertRecords(client, insertEntries); // record 추가! - console.log(resultRecords); + console.log(insertEntries); + // const resultRecords = await recordDB.insertRecords(client, insertEntries); // record 추가! + // console.log(resultRecords); const slackMessage = `폭파된 방 목록: ${failRoomIds} / 살아남은 방 목록: ${successRoomIds}`; slackAPI.sendMessageToSlack(slackMessage, slackAPI.DEV_WEB_HOOK_ERROR_MONITORING); } catch (error) {