Skip to content

Commit

Permalink
fix: 12월 임시대응 삭제, 리뉴얼 친바에서 사서 명단 가져오도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
not-using committed Jan 2, 2024
1 parent 917874f commit 8ccc54c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
8 changes: 0 additions & 8 deletions src/constants/decemberRotation.js

This file was deleted.

21 changes: 18 additions & 3 deletions src/services/shift.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { decemberRotation } from '../constants/decemberRotation.js';
import { SHIFT, SHIFT_WEEKEND } from '../constants/events.js';
import { TOGETHER_RANGE } from '../constants/sheet.js';
import { confirmMessage } from '../messages/confirmMessage.js';
import { httpClientForSheet } from '../utils/httpClient.js';
import {
httpClientForSheet,
httpClientForTogether,
} from '../utils/httpClient.js';
import { sendBlocks } from '../utils/slackChat.js';

const WEEKS = [1, 2, 3, 4, 5];
Expand All @@ -15,13 +17,26 @@ export const sendShiftConfirmation = async () => {
today.slice(5, 10)
);

const todayLibrarians = decemberRotation[today];
const todayLibrarians = await getTodayLibrariansFromTogether();
const todayLibrariansId = await getLibrariansIdFromSheet(todayLibrarians);

await Promise.all(todayLibrariansId.map((id) => sendBlocks(id, message)));
console.log('shift', todayLibrarians);
};

const getTodayLibrariansFromTogether = async () => {
const rotations = await httpClientForTogether
.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}`)
Expand Down

0 comments on commit 8ccc54c

Please sign in to comment.