Skip to content

Commit

Permalink
Merge pull request #190 from TeamSparker/feature/#189
Browse files Browse the repository at this point in the history
[REFACTOR] 대기방 상세 조회 참여자 정렬 기준 변경
  • Loading branch information
youngkwon02 authored Feb 17, 2022
2 parents c1e1724 + 95abe9e commit c8b3208
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions functions/api/routes/room/roomDetailGET.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ module.exports = async (req, res) => {

let myRecord = null;

let otherRecords = [];
let considerRecords = [];
let noneRecords = [];
let restRecords = [];
let doneRecords = [];

records.map((record) => {
if (record.userId === user.userId) {
Expand All @@ -73,22 +76,47 @@ module.exports = async (req, res) => {
rest: record.rest,
};
} else {
otherRecords.push({
recordId: record.recordId,
userId: record.userId,
profileImg: record.profileImg,
nickname: record.nickname,
status: record.status,
});
if (record.status === 'CONSIDER') {
considerRecords.push({
recordId: record.recordId,
userId: record.userId,
profileImg: record.profileImg,
nickname: record.nickname,
status: record.status,
});
} else if (record.status === 'NONE') {
noneRecords.push({
recordId: record.recordId,
userId: record.userId,
profileImg: record.profileImg,
nickname: record.nickname,
status: record.status,
});
} else if (record.status === 'REST') {
restRecords.push({
recordId: record.recordId,
userId: record.userId,
profileImg: record.profileImg,
nickname: record.nickname,
status: record.status,
});
} else {
doneRecords.push({
recordId: record.recordId,
userId: record.userId,
profileImg: record.profileImg,
nickname: record.nickname,
status: record.status,
});
}
}
});

const otherRecords = [...considerRecords, ...noneRecords, ...restRecords, ...doneRecords];

const receivedSpark = await sparkDB.countSparkByRecordId(client, myRecord.recordId);
myRecord.receivedSpark = parseInt(receivedSpark.count);

console.log('myRecrod', myRecord);
console.log('otherRecords', otherRecords);

const data = {
roomId: room.roomId,
roomName: room.roomName,
Expand Down

0 comments on commit c8b3208

Please sign in to comment.