United groups to the top Closes #768

This commit is contained in:
Kalle
2022-03-27 14:59:44 +03:00
parent 471d467953
commit be63db096e

View File

@@ -138,13 +138,17 @@ export function uniteGroups({
removeCaptainsFromOther,
unitedGroupIsRanked,
}: UniteGroupsArgs) {
const survivingGroupUpdatedTimestamps = {
lastActionAt: new Date(),
createdAt: new Date(),
};
return db.$transaction([
db.lfgGroupMember.updateMany({
where: { groupId: otherGroupId },
data: {
groupId: survivingGroupId,
captain: removeCaptainsFromOther ? false : undefined,
// TODO: also reset message
},
}),
db.lfgGroup.delete({ where: { id: otherGroupId } }),
@@ -157,8 +161,8 @@ export function uniteGroups({
where: { id: survivingGroupId },
data:
typeof unitedGroupIsRanked === "boolean"
? { ranked: unitedGroupIsRanked, lastActionAt: new Date() }
: { lastActionAt: new Date() },
? { ranked: unitedGroupIsRanked, ...survivingGroupUpdatedTimestamps }
: survivingGroupUpdatedTimestamps,
}),
]);
}