Skip to content

Conversation

@kmc7468
Copy link
Member

@kmc7468 kmc7468 commented Nov 18, 2025

Summary

It closes #651

Extra info

회의를 통해 이모지와 숫자 식별자 중 무엇이 더 직관적일지 결정 후, 둘 중 하나만 유지할 예정입니다.

일단은 도착 여부를 정산 이후에는 변경하지 못하도록 해 두었는데, 구체적인 도착 여부 설정 가능한 조건과, 채팅 전송 여부를 회의를 통해 결정하면 좋을 것 같습니다.

@kmc7468 kmc7468 self-assigned this Nov 18, 2025
@kmc7468 kmc7468 linked an issue Nov 18, 2025 that may be closed by this pull request
2 tasks
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an arrival confirmation feature (#651) that allows participants to indicate they've arrived at the departure location. It also introduces optional room identifiers (emoji and numeric) to help distinguish between rooms departing around the same time. According to the PR description, the team will decide which identifier type to keep (emoji or numeric) after discussions.

Key Changes:

  • Added toggleArrivalHandler endpoint to allow participants to mark their arrival status before departure
  • Implemented room identifier allocation system with emoji and numeric options
  • Extended the room and participant schemas to support these new features

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/modules/roomIdentifier.ts New module for allocating unique emoji and numeric identifiers to rooms within a 30-minute time window
src/services/rooms.ts Added toggleArrivalHandler for toggling arrival status; updated createHandler to allocate room identifiers
src/routes/rooms.ts Added /arrival POST endpoint with validation for the new arrival toggle feature
src/routes/docs/schemas/roomsSchema.ts Added Zod schema validation for toggleArrivalHandler with roomId and isArrived fields
src/modules/stores/mongo.ts Extended participant schema with optional isArrived boolean; extended room schema with optional emojiIdentifier and numericIdentifier strings
src/modules/populates/rooms.ts Updated room population and formatting logic to include new identifier and arrival fields in API responses

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@thxx132 thxx132 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 이제 numeric 이랑 비교해보고 괜찮은 것으로 가면 될 것 같아요

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +809 to +862
export const updateArrivalHandler: RequestHandler = async (req, res) => {
try {
const { roomId, isArrived } = req.body as UpdateArrivalBody;

const user = await userModel.findOne({ _id: req.userOid, withdraw: false });
if (!user) {
return res
.status(400)
.json({ error: "Rooms/:id/updateArrival : User not found" });
}

const roomObject = await roomModel
.findOneAndUpdate(
{
_id: roomId,
part: {
$elemMatch: {
user: user._id,
settlementStatus: { $nin: ["paid", "sent"] },
},
},
},
{ $set: { "part.$.isArrived": isArrived } },
{ new: true }
)
.lean()
.populate<RoomPopulatePath>(roomPopulateOption);

if (!roomObject) {
const participantExists = await roomModel.exists({
_id: roomId,
"part.user": user._id,
});
if (participantExists) {
return res.status(400).json({
error:
"Rooms/:id/updateArrival : cannot update after settlement or payment",
});
}
return res.status(404).json({
error: "Rooms/:id/updateArrival : cannot find corresponding room",
});
}

// 수정한 방 정보를 반환합니다.
const isOver = getIsOver(roomObject, user._id.toString());
return res.send(formatSettlement(roomObject, { isOver }));
} catch (err) {
logger.error(err);
return res.status(500).json({
error: "Rooms/:id/updateArrival : internal server error",
});
}
};
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new updateArrivalHandler function lacks test coverage. Given that the codebase has comprehensive test coverage for room handlers (as seen in test/services/rooms.ts with tests for createHandler, joinHandler, commitSettlementHandler, etc.), this new handler should also have corresponding tests to verify:

  1. Successful arrival status updates
  2. Rejection when user is not found
  3. Rejection when user is not a participant
  4. Rejection when settlement/payment status prevents updates
  5. Correct response format

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +47
export const allocateEmojiIdentifier = async (departureTime: Date) => {
const nearbyRooms = await roomModel
.find(
{
time: {
$gte: departureTime.getTime() - timeWindow,
$lte: departureTime.getTime() + timeWindow,
},
},
"emojiIdentifier"
)
.lean();

const usedEmojis = new Set(
nearbyRooms
.map((room) => room.emojiIdentifier)
.filter((identifier): identifier is string => Boolean(identifier))
);
const availableEmojis = emojis.filter((emoji) => !usedEmojis.has(emoji));

return availableEmojis.length > 0
? availableEmojis[crypto.randomInt(availableEmojis.length)]
: undefined;
};
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new allocateEmojiIdentifier function lacks test coverage. Given that the codebase has test coverage for other modules, this function should have tests to verify:

  1. Correct emoji allocation when emojis are available
  2. Returns undefined when all emojis are in use
  3. Proper filtering of already-used emojis
  4. Correct time window filtering of nearby rooms

Copilot uses AI. Check for mistakes.

const createTime = new Date(time);
const departureTime = new Date(time);
const createTime = new Date(departureTime);
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable departureTime is created from time, and then createTime is created from departureTime, but this is redundant. Line 52 should directly use time instead:

const departureTime = new Date(time);
const createTime = new Date(time);

This is more efficient and clearer in intent since both are independent Date objects created from the same source.

Suggested change
const createTime = new Date(departureTime);
const createTime = new Date(time);

Copilot uses AI. Check for mistakes.
@sparcs-kaist sparcs-kaist deleted a comment from Copilot AI Jan 9, 2026
@sparcs-kaist sparcs-kaist deleted a comment from Copilot AI Jan 9, 2026
@sparcs-kaist sparcs-kaist deleted a comment from Copilot AI Jan 9, 2026
@sparcs-kaist sparcs-kaist deleted a comment from Copilot AI Jan 9, 2026
@sparcs-kaist sparcs-kaist deleted a comment from Copilot AI Jan 9, 2026
@sparcs-kaist sparcs-kaist deleted a comment from Copilot AI Jan 9, 2026
Copy link
Contributor

@thxx132 thxx132 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 입니다! 컨플릭트 해결하고 프론트랑 같이 머지하면 될 것 같아요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

도착 확인 기능

4 participants