From 7afe19afa7e6b1363f592d418b58443b3be333eb Mon Sep 17 00:00:00 2001 From: sujikim Date: Fri, 5 Jan 2024 16:28:55 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=B9=9C=EB=B0=94=20=EC=82=AC=EC=84=9C?= =?UTF-8?q?=20=EB=AA=85=EB=8B=A8=20=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8A=94=20?= =?UTF-8?q?api=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /rotations => /rotations/today 환경변수는 수동으로 수정함 --- src/services/shift.js | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/services/shift.js b/src/services/shift.js index f49ec0b..c8c3d20 100644 --- a/src/services/shift.js +++ b/src/services/shift.js @@ -17,8 +17,8 @@ export const sendShiftConfirmation = async () => { today.slice(5, 10) ); - const todayLibrarians = await getTodayLibrariansFromTogether(); - const todayLibrariansId = await getLibrariansIdFromSheet(todayLibrarians); + const [todayLibrarians, todayLibrariansId] = + await getTodayLibrariansFromTogether(); await Promise.all(todayLibrariansId.map((id) => sendBlocks(id, message))); console.log('shift', todayLibrarians); @@ -29,20 +29,11 @@ const getTodayLibrariansFromTogether = async () => { .get('/') .then((response) => response.data); - return rotations - .filter( - ({ month, day }) => - month === new Date().getMonth() + 1 && day === new Date().getDay() - ) - .map((rotation) => rotation.intraId); -}; - -const getLibrariansIdFromSheet = async (targets) => { - const librarians = await httpClientForSheet - .get(`/${TOGETHER_RANGE}`) - .then((response) => response.data.values); // [[NAME, SLACK_ID], [NAME, SLACK_ID], ...] 형식으로 반환됨 - - return librarians - .filter((item) => targets.includes(item[0])) - .map((item) => item[1]); + return rotations.reduce( + ([name, slack], { nickname, slackMemberId }) => [ + [...name, nickname], + [...slack, slackMemberId], + ], + [[], []] + ); };