From cfd1aacf5cf2c3c1a00114fc69c536b96067203d Mon Sep 17 00:00:00 2001 From: xxeol Date: Tue, 18 Jan 2022 21:37:13 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EC=B5=9C=EC=B4=88=20=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=EC=8B=9C=20entry=EC=97=90=20thumbnail=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/room/roomRecordPOST.js | 3 +++ functions/db/room.js | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/functions/api/routes/room/roomRecordPOST.js b/functions/api/routes/room/roomRecordPOST.js index e4a54a8..8854611 100644 --- a/functions/api/routes/room/roomRecordPOST.js +++ b/functions/api/routes/room/roomRecordPOST.js @@ -60,6 +60,9 @@ module.exports = async (req, res) => { } const uploadedRecord = await recordDB.uploadRecord(client, record.recordId, certifyingImg[0], timerRecord); + if (!entry.thumbnail) { + await roomDB.updateThumbnail(client, entry.entryId, certifyingImg[0]); + } const data = { userId: user.userId, diff --git a/functions/db/room.js b/functions/db/room.js index 611dc89..7ba1674 100644 --- a/functions/db/room.js +++ b/functions/db/room.js @@ -404,6 +404,18 @@ const updateLife = async(client, failCount, roomIds) => { return convertSnakeToCamel.keysToCamel(rows); } +const updateThumbnail = async(client, entryId, img) => { + const { rows } = await client.query( + ` + UPDATE spark.entry e + SET thumbnail = $2 + WHERE entry_id = $1 + `, + [entryId, img] + ); + return convertSnakeToCamel.keysToCamel(rows[0]); +} + module.exports = { addRoom, isCodeUnique, @@ -427,4 +439,5 @@ module.exports = { updateLife, getFailRecords, getEntriesByRoomIds, + updateThumbnail }; From 9caab773326881db834a81a223c26d6304457ff9 Mon Sep 17 00:00:00 2001 From: xxeol Date: Tue, 18 Jan 2022 21:40:49 +0900 Subject: [PATCH 2/3] =?UTF-8?q?style:=20=20TODO=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/room/roomListGET.js | 4 ++-- functions/api/routes/room/roomRecordPOST.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/api/routes/room/roomListGET.js b/functions/api/routes/room/roomListGET.js index 58aad1b..69bba32 100644 --- a/functions/api/routes/room/roomListGET.js +++ b/functions/api/routes/room/roomListGET.js @@ -34,9 +34,9 @@ module.exports = async (req, res) => { const rawRooms = await roomDB.getRoomsByUserId(client, user.userId); let waitingRooms = rawRooms.filter((rawRoom) => rawRoom.status === "NONE"); - waitingRooms = _.sortBy(waitingRooms, 'createdAt').reverse(); + waitingRooms = _.sortBy(waitingRooms, 'createdAt').reverse(); // 최근에 생선된 대기방이 위로 let ongoingRooms = rawRooms.filter((rawRoom) => rawRoom.status === "ONGOING"); - ongoingRooms = _.sortBy(ongoingRooms, 'startAt').reverse(); + ongoingRooms = _.sortBy(ongoingRooms, 'startAt').reverse(); // 최근에 시작한 습관방이 위로 console.log("waitingRooms", waitingRooms); console.log("ongoingRooms", ongoingRooms); const waitingRoomIds = [...new Set(waitingRooms.filter(Boolean).map((room) => room.roomId))]; diff --git a/functions/api/routes/room/roomRecordPOST.js b/functions/api/routes/room/roomRecordPOST.js index 8854611..ce71a35 100644 --- a/functions/api/routes/room/roomRecordPOST.js +++ b/functions/api/routes/room/roomRecordPOST.js @@ -62,6 +62,7 @@ module.exports = async (req, res) => { const uploadedRecord = await recordDB.uploadRecord(client, record.recordId, certifyingImg[0], timerRecord); if (!entry.thumbnail) { await roomDB.updateThumbnail(client, entry.entryId, certifyingImg[0]); + // @TODO 첫번째 습관 인증 축하 알림 } const data = { From 999209e213b637a29595ef587ce0d2460a23badc Mon Sep 17 00:00:00 2001 From: xxeol Date: Tue, 18 Jan 2022 21:42:00 +0900 Subject: [PATCH 3/3] =?UTF-8?q?style:=20=EC=A3=BC=EC=84=9D=20=EC=98=A4?= =?UTF-8?q?=ED=83=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions/api/routes/room/roomListGET.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/api/routes/room/roomListGET.js b/functions/api/routes/room/roomListGET.js index 69bba32..60a975b 100644 --- a/functions/api/routes/room/roomListGET.js +++ b/functions/api/routes/room/roomListGET.js @@ -34,7 +34,7 @@ module.exports = async (req, res) => { const rawRooms = await roomDB.getRoomsByUserId(client, user.userId); let waitingRooms = rawRooms.filter((rawRoom) => rawRoom.status === "NONE"); - waitingRooms = _.sortBy(waitingRooms, 'createdAt').reverse(); // 최근에 생선된 대기방이 위로 + waitingRooms = _.sortBy(waitingRooms, 'createdAt').reverse(); // 최근에 생성된 대기방이 위로 let ongoingRooms = rawRooms.filter((rawRoom) => rawRoom.status === "ONGOING"); ongoingRooms = _.sortBy(ongoingRooms, 'startAt').reverse(); // 최근에 시작한 습관방이 위로 console.log("waitingRooms", waitingRooms);