feat: allow admins to add match participants
This commit is contained in:
1 parent
8aff1be225
commit
24983aeb09
11 files changed
+1019
-19
No files matched your search
@@ -13,6 +13,7 @@ import {
|
||||
MatchDocument,
|
||||
MatchSeriesResult,
|
||||
MatchStatus,
|
||||
POSITIONS,
|
||||
Position,
|
||||
PositionPreference,
|
||||
TierInfo,
|
||||
@@ -64,7 +65,7 @@ interface MatchListFilter {
|
||||
interface JoinMatchParams {
|
||||
matchId: mongoose.Types.ObjectId;
|
||||
userId: mongoose.Types.ObjectId;
|
||||
preferredPositions: PositionPreference[];
|
||||
preferredPositions?: PositionPreference[];
|
||||
// 특정 RiotAccount(puuid)로 참가하고 싶을 때 지정. 없으면 primary 사용.
|
||||
riotPuuid?: string;
|
||||
}
|
||||
@@ -293,7 +294,10 @@ export class MatchService {
|
||||
tagLine: selectedRiot?.tagLine,
|
||||
profileIconId: selectedRiot?.profileIconId,
|
||||
tier: selectedTier,
|
||||
preferredPositions: params.preferredPositions,
|
||||
preferredPositions: this.resolveJoinPreferredPositions(
|
||||
params.preferredPositions,
|
||||
user.preferredPositions,
|
||||
),
|
||||
joinedAt: new Date(),
|
||||
excluded: false,
|
||||
});
|
||||
@@ -436,6 +440,28 @@ export class MatchService {
|
||||
};
|
||||
}
|
||||
|
||||
private resolveJoinPreferredPositions(
|
||||
requested: PositionPreference[] | undefined,
|
||||
saved: PositionPreference[] | undefined,
|
||||
): PositionPreference[] {
|
||||
const source = requested?.length
|
||||
? requested
|
||||
: saved?.length
|
||||
? saved
|
||||
: POSITIONS.map((position, index) => ({
|
||||
position,
|
||||
priority: index + 1,
|
||||
}));
|
||||
|
||||
return [...source]
|
||||
.sort((left, right) => left.priority - right.priority)
|
||||
.slice(0, 5)
|
||||
.map((preference, index) => ({
|
||||
position: preference.position,
|
||||
priority: index + 1,
|
||||
}));
|
||||
}
|
||||
|
||||
private buildListFilter(query: ListMatchesQuery): MatchListFilter {
|
||||
const filter: MatchListFilter = {
|
||||
communityId: query.communityId,
|
||||
|
||||
Reference in new issue
Block a user