Skip to content

Commit

Permalink
Merge branch 'develop' into feature/#10-CodeCreation
Browse files Browse the repository at this point in the history
  • Loading branch information
davbrican authored Jul 3, 2021
2 parents 7475dc5 + 436b19c commit 743489b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
41 changes: 36 additions & 5 deletions consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,22 +390,53 @@ async function notifyParticipants(sessionName, io) {

Logger.dbg("notifyParticipants - Re-assigning rooms to avoid race conditions!");

var femaleList = []
var nonMaleList = []
var maleList = []
for(j=0;j<participants.length;j++) {
if (participants[j].gender == "Male") {
maleList.push(participants[j]);
}
else if (participants[j].gender == "Female") {
femaleList.push(participants[j]);
else {
nonMaleList.push(participants[j]);
}
}

var firstList = []
var secondList = []

if (nonMaleList.length != maleList.length) {
if (nonMaleList.length < maleList.length) {
const sizeDifference = maleList.length - nonMaleList.length;
firstList = nonMaleList;
secondList = maleList.slice(0, maleList.length - sizeDifference);
for(let j=maleList.length - sizeDifference;j<maleList.length;j++) {
if(j%2==0) {
firstList.push(maleList[j]);
}
else {
secondList.push(maleList[j]);
}
}
} else {
const sizeDifference = nonMaleList.length - maleList.length;
firstList = maleList;
secondList = nonMaleList.slice(0, nonMaleList.length - sizeDifference);
for(let j=nonMaleList.length - sizeDifference;j<nonMaleList.length;j++) {
if(j%2==0) {
firstList.push(nonMaleList[j]);
}
else {
secondList.push(nonMaleList[j]);
}
}
}
}

participantNumber = 0;

for(i=0;i<roomCount;i++){
let peer1 = femaleList[i];
let peer2 = maleList[i];
let peer1 = firstList[i];
let peer2 = secondList[i];

peer1.room = i+initialRoom;
peer2.room = i+initialRoom;
Expand Down
1 change: 1 addition & 0 deletions routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ router.post("/signup", async (req, res) => {
break;
}
}


const newUser = new User(req.body);
newUser.code = code;
Expand Down

0 comments on commit 743489b

Please sign in to comment.