Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] 생명 타임라인 조회 title에 감소 개수 반영 #436

Merged
merged 1 commit into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion functions/db/lifeTimeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const addLifeTimeline = async (client, timelines) => {
const { rows } = await client.query(
`
INSERT INTO spark.life_timeline
(receiver_id, room_id, is_decrease, profile_1, profile_2)
(receiver_id, room_id, is_decrease, decrease_count, profile_1, profile_2)
VALUES
${timelines.join()}
RETURNING *
Expand Down
4 changes: 3 additions & 1 deletion functions/scheduler/funcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,21 @@ const checkLife = async () => {
decreaseMessageUsers = await roomDB.getAllUsersByIds(client, lifeDeductionRoomIds);
}
let failProfiles = {}; // 인증 안한 사용자 프로필 사진, key: roomId, value: profile 배열
let decreaseCount = {}; // 인증 안한 사용자 수, key: roomId, value: decreaseCount
let decreaseMessage = [];
for (let i = 0; i < decreaseMessageUsers.length; i++) {
const { userId, roomId } = decreaseMessageUsers[i];
if (!Object.keys(failProfiles).includes(roomId)) {
let profiles = await roomDB.getFailProfiles(client, roomId);
profiles = profiles.map((p) => p.profile).sort(() => Math.random() - 0.5);
decreaseCount[roomId] = profiles.length;
while (profiles.length < 2) {
profiles.push(null);
}
failProfiles[roomId] = profiles;
}

decreaseMessage.push(`('${userId}', '${roomId}', true, '${failProfiles[roomId][0]}', '${failProfiles[roomId][1]}')`);
decreaseMessage.push(`('${userId}', '${roomId}', true, ${decreaseCount[roomId]}, '${failProfiles[roomId][0]}', '${failProfiles[roomId][1]}')`);
}

// 생명 감소시 Time Line Insert
Expand Down