Skip to content
Snippets Groups Projects
Commit f4359f42 authored by 조대희's avatar 조대희
Browse files

refactor: 문자열 -> 정수 변환

parent 544cd55d
No related branches found
No related tags found
1 merge request!43배포코드 master브랜치로
......@@ -119,8 +119,8 @@ class MeetingService {
);
const time_indices = Array.from(
{ length: time_idx_end - time_idx_start + 1 },
(_, i) => time_idx_start + i
{ length: parseInt(time_idx_end) - parseInt(time_idx_start) + 1 },
(_, i) => (parseInt(time_idx_start) + i).toString()
);
await ScheduleService.createSchedules({
userId: created_by,
......
......@@ -10,11 +10,17 @@ class ScheduleService {
* @param {object} [transaction] - Sequelize 트랜잭션 객체 -> 미팅방에서 쓰기위해 트랜잭션을 넘겨받는걸 추가
*/
async createSchedules({ userId, title, is_fixed, time_indices }, transaction = null) {
const parsedTimeIndices = time_indices.map(idx => parseInt(idx, 10));
if (!userId || !title || !parsedTimeIndices.length) {
throw new Error('Required parameters missing');
}
const overlaps = await Schedule.findAll({
where: {
user_id: userId,
time_idx: {
[Op.in]: time_indices
[Op.in]: parsedTimeIndices
}
},
transaction
......@@ -24,25 +30,14 @@ class ScheduleService {
throw new Error(`Schedule overlaps at time_idx ${overlaps[0].time_idx}`);
}
const scheduleData = time_indices.map(time_idx => ({
const scheduleData = parsedTimeIndices.map(time_idx => ({
user_id: userId,
title,
time_idx: parseInt(time_idx, 10),
time_idx,
is_fixed
}));
try {
if (!userId || !title || !time_indices) {
throw new Error('Required parameters missing');
}
console.log('Creating schedule with data:', {
userId,
title,
is_fixed,
time_indices
});
const createdSchedules = await Schedule.bulkCreate(scheduleData, {
transaction,
returning: true,
......@@ -54,7 +49,7 @@ class ScheduleService {
user_id: userId,
title,
is_fixed,
time_indices,
time_indices: parsedTimeIndices,
createdAt: createdSchedules[0].createdAt,
updatedAt: createdSchedules[0].updatedAt
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment