Skip to content

Commit

Permalink
Merge pull request #436 from TeamSparker/fix/#433
Browse files Browse the repository at this point in the history
[FIX] 생명 타임라인 조회 title에 감소 개수 반영
  • Loading branch information
youngkwon02 authored Oct 1, 2022
2 parents c095f96 + 8671623 commit b273a3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit b273a3f

Please sign in to comment.