Skip to content

Commit 79e40bc

Browse files
committed
hotfix: change default attendees 2 to 1
1 parent 76dd518 commit 79e40bc

File tree

2 files changed

+70
-69
lines changed

2 files changed

+70
-69
lines changed

Diff for: src/rotation/rotations.service.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ export class RotationsService {
672672
const day = new Date(year, month - 1, i).getDate();
673673

674674
if (!holidayArrayOfMonth.includes(day)) {
675-
const tmpDayObject: DayObject = { day, arr: [0, 0] };
675+
// const tmpDayObject: DayObject = { day, arr: [0, 0] };
676+
const tmpDayObject: DayObject = { day, arr: [0] };
676677

677678
tmpWeekArray.push(tmpDayObject);
678679

Diff for: src/rotation/utils/rotation.ts

+68-68
Original file line numberDiff line numberDiff line change
@@ -113,74 +113,74 @@ export function createRotation(
113113
monthArrayInfo[i][j].arr[arrIndex++] = participant1.userId;
114114
}
115115

116-
shuffle(rotationAttendeeInfo);
117-
sortByArray(rotationAttendeeInfo);
118-
119-
let participant2 = undefined;
120-
for (let k = 0; k < rotationAttendeeInfo.length; k++) {
121-
if (
122-
rotationAttendeeInfo[k].attended < participation &&
123-
!rotationAttendeeInfo[k].attendLimit.includes(
124-
monthArrayInfo[i][j].day,
125-
) &&
126-
!monthArrayInfo[i][j].arr.includes(rotationAttendeeInfo[k].userId)
127-
) {
128-
participant2 = rotationAttendeeInfo[k];
129-
participant2.attended += 1;
130-
break;
131-
}
132-
}
133-
if (canDuplicate && participant2 === undefined) {
134-
for (let k = 0; k < rotationAttendeeInfo.length; k++) {
135-
if (
136-
rotationAttendeeInfo[k].attended < participation + 1 &&
137-
!rotationAttendeeInfo[k].attendLimit.includes(
138-
monthArrayInfo[i][j].day,
139-
) &&
140-
!monthArrayInfo[i][j].arr.includes(rotationAttendeeInfo[k].userId)
141-
) {
142-
participant2 = rotationAttendeeInfo[k];
143-
participant2.attended += 1;
144-
break;
145-
}
146-
}
147-
}
148-
if (participant2 === undefined) {
149-
participation += 1;
150-
if (j > 0) {
151-
j -= 1;
152-
} else {
153-
j = -1;
154-
}
155-
if (participant1 && isLooped === false) {
156-
if (isLoopedAgain === true) {
157-
participation -= 1;
158-
isLoopedAgain = false;
159-
continue;
160-
}
161-
const index = rotationAttendeeInfo.findIndex(
162-
(obj) => obj.userId === participant1.userId,
163-
);
164-
continueIndex = index;
165-
checkContinue = true;
166-
isLooped = true;
167-
isLoopedAgain = true;
168-
participant1.attended -= 1;
169-
monthArrayInfo[i][j + 1].arr[0] = 0;
170-
} else if (isLooped) {
171-
participation -= 1;
172-
isLooped = false;
173-
isLoopedAgain = false;
174-
j += 1;
175-
}
176-
continue;
177-
} else {
178-
continueIndex = 0;
179-
checkContinue = false;
180-
isLooped = false;
181-
isLoopedAgain = false;
182-
monthArrayInfo[i][j].arr[arrIndex--] = participant2.userId;
183-
}
116+
// shuffle(rotationAttendeeInfo);
117+
// sortByArray(rotationAttendeeInfo);
118+
//
119+
// let participant2 = undefined;
120+
// for (let k = 0; k < rotationAttendeeInfo.length; k++) {
121+
// if (
122+
// rotationAttendeeInfo[k].attended < participation &&
123+
// !rotationAttendeeInfo[k].attendLimit.includes(
124+
// monthArrayInfo[i][j].day,
125+
// ) &&
126+
// !monthArrayInfo[i][j].arr.includes(rotationAttendeeInfo[k].userId)
127+
// ) {
128+
// participant2 = rotationAttendeeInfo[k];
129+
// participant2.attended += 1;
130+
// break;
131+
// }
132+
// }
133+
// if (canDuplicate && participant2 === undefined) {
134+
// for (let k = 0; k < rotationAttendeeInfo.length; k++) {
135+
// if (
136+
// rotationAttendeeInfo[k].attended < participation + 1 &&
137+
// !rotationAttendeeInfo[k].attendLimit.includes(
138+
// monthArrayInfo[i][j].day,
139+
// ) &&
140+
// !monthArrayInfo[i][j].arr.includes(rotationAttendeeInfo[k].userId)
141+
// ) {
142+
// participant2 = rotationAttendeeInfo[k];
143+
// participant2.attended += 1;
144+
// break;
145+
// }
146+
// }
147+
// }
148+
// if (participant2 === undefined) {
149+
// participation += 1;
150+
// if (j > 0) {
151+
// j -= 1;
152+
// } else {
153+
// j = -1;
154+
// }
155+
// if (participant1 && isLooped === false) {
156+
// if (isLoopedAgain === true) {
157+
// participation -= 1;
158+
// isLoopedAgain = false;
159+
// continue;
160+
// }
161+
// const index = rotationAttendeeInfo.findIndex(
162+
// (obj) => obj.userId === participant1.userId,
163+
// );
164+
// continueIndex = index;
165+
// checkContinue = true;
166+
// isLooped = true;
167+
// isLoopedAgain = true;
168+
// participant1.attended -= 1;
169+
// monthArrayInfo[i][j + 1].arr[0] = 0;
170+
// } else if (isLooped) {
171+
// participation -= 1;
172+
// isLooped = false;
173+
// isLoopedAgain = false;
174+
// j += 1;
175+
// }
176+
// continue;
177+
// } else {
178+
// continueIndex = 0;
179+
// checkContinue = false;
180+
// isLooped = false;
181+
// isLoopedAgain = false;
182+
// monthArrayInfo[i][j].arr[arrIndex--] = participant2.userId;
183+
// }
184184
}
185185
}
186186

0 commit comments

Comments
 (0)