feat: redesign auction engine with redis sot
This commit is contained in:
1 parent
737702d78c
commit
e8bb20d988
75 files changed
+12737
-542
No files matched your search
@@ -52,7 +52,7 @@ type CaptainSelectionSlot = {
|
||||
|
||||
type CaptainSelection = {
|
||||
userId: string;
|
||||
initialPoints: string;
|
||||
initialTeamBidPointAmountInput: string;
|
||||
};
|
||||
|
||||
const DEFAULT_AUCTION_MAX_TIMER_SECONDS = 30;
|
||||
@@ -2387,17 +2387,23 @@ export default function MatchDetailPage() {
|
||||
const [captainSelections, setCaptainSelections] = useState<
|
||||
Record<string, CaptainSelection>
|
||||
>({});
|
||||
const [topTierThreshold, setTopTierThreshold] =
|
||||
const [
|
||||
topTierAuctionPriorityThreshold,
|
||||
setTopTierAuctionPriorityThreshold,
|
||||
] =
|
||||
useState<AuctionTopTierThreshold>("NONE");
|
||||
const [manualTopTierUserIds, setManualTopTierUserIds] = useState<string[]>(
|
||||
[],
|
||||
);
|
||||
const [maxTimerSeconds, setMaxTimerSeconds] = useState(
|
||||
const [
|
||||
manualTopTierAuctionPriorityUserIds,
|
||||
setManualTopTierAuctionPriorityUserIds,
|
||||
] = useState<string[]>([]);
|
||||
const [
|
||||
maximumBidRoundDurationSecondsInput,
|
||||
setMaximumBidRoundDurationSecondsInput,
|
||||
] = useState(
|
||||
String(DEFAULT_AUCTION_MAX_TIMER_SECONDS),
|
||||
);
|
||||
const [bidExtensionSeconds, setBidExtensionSeconds] = useState(
|
||||
String(DEFAULT_AUCTION_BID_EXTENSION_SECONDS),
|
||||
);
|
||||
const [bidRoundExtensionSecondsInput, setBidRoundExtensionSecondsInput] =
|
||||
useState(String(DEFAULT_AUCTION_BID_EXTENSION_SECONDS));
|
||||
const [manualResultStartTime, setManualResultStartTime] = useState("");
|
||||
const [manualResultEndTime, setManualResultEndTime] = useState("");
|
||||
const [manualRiotMatchId, setManualRiotMatchId] = useState("");
|
||||
@@ -2550,29 +2556,33 @@ export default function MatchDetailPage() {
|
||||
});
|
||||
|
||||
const startAuctionMutation = useMutation({
|
||||
mutationFn: () =>
|
||||
mutationFn: (startAuctionRequestId: string) =>
|
||||
apiFetch(`/communities/${DEFAULT_COMMUNITY_ID}/matches/${id}/auction`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
startAuctionRequestId,
|
||||
captains: buildCaptainSlots(matchQuery.data?.participants ?? []).map(
|
||||
(slot) => ({
|
||||
teamIndex: slot.teamIndex,
|
||||
userId: captainSelections[captainSlotKey(slot)]?.userId,
|
||||
initialPoints:
|
||||
initialTeamBidPointAmount:
|
||||
parseInitialPointsInput(
|
||||
captainSelections[captainSlotKey(slot)]?.initialPoints ?? "",
|
||||
captainSelections[captainSlotKey(slot)]
|
||||
?.initialTeamBidPointAmountInput ?? "",
|
||||
) ?? 1000,
|
||||
}),
|
||||
),
|
||||
initialPoints: 1000,
|
||||
topTierThreshold,
|
||||
manualTopTierUserIds:
|
||||
topTierThreshold === "MANUAL" ? selectedManualTopTierUserIds : [],
|
||||
maxTimerSeconds:
|
||||
parseAuctionSecondsInput(maxTimerSeconds, 5) ??
|
||||
initialTeamBidPointAmount: 1000,
|
||||
topTierAuctionPriorityThreshold,
|
||||
manualTopTierAuctionPriorityUserIds:
|
||||
topTierAuctionPriorityThreshold === "MANUAL"
|
||||
? selectedManualTopTierUserIds
|
||||
: [],
|
||||
maximumBidRoundDurationSeconds:
|
||||
parseAuctionSecondsInput(maximumBidRoundDurationSecondsInput, 5) ??
|
||||
DEFAULT_AUCTION_MAX_TIMER_SECONDS,
|
||||
bidExtensionSeconds:
|
||||
parseAuctionSecondsInput(bidExtensionSeconds, 0) ??
|
||||
bidRoundExtensionSeconds:
|
||||
parseAuctionSecondsInput(bidRoundExtensionSecondsInput, 0) ??
|
||||
DEFAULT_AUCTION_BID_EXTENSION_SECONDS,
|
||||
}),
|
||||
}),
|
||||
@@ -2681,7 +2691,8 @@ export default function MatchDetailPage() {
|
||||
if (currentIsValid) {
|
||||
next[key] = {
|
||||
userId: currentUserId,
|
||||
initialPoints: currentSelection?.initialPoints ?? "1000",
|
||||
initialTeamBidPointAmountInput:
|
||||
currentSelection?.initialTeamBidPointAmountInput ?? "1000",
|
||||
};
|
||||
usedUserIds.add(currentUserId);
|
||||
continue;
|
||||
@@ -2692,7 +2703,8 @@ export default function MatchDetailPage() {
|
||||
);
|
||||
next[key] = {
|
||||
userId: fallback?.userId ?? "",
|
||||
initialPoints: currentSelection?.initialPoints ?? "1000",
|
||||
initialTeamBidPointAmountInput:
|
||||
currentSelection?.initialTeamBidPointAmountInput ?? "1000",
|
||||
};
|
||||
if (fallback) usedUserIds.add(fallback.userId);
|
||||
}
|
||||
@@ -2754,7 +2766,8 @@ export default function MatchDetailPage() {
|
||||
const hasValidCaptainInitialPoints = captainSlots.every((slot) =>
|
||||
Boolean(
|
||||
parseInitialPointsInput(
|
||||
captainSelections[captainSlotKey(slot)]?.initialPoints ?? "",
|
||||
captainSelections[captainSlotKey(slot)]
|
||||
?.initialTeamBidPointAmountInput ?? "",
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -2764,12 +2777,16 @@ export default function MatchDetailPage() {
|
||||
const manualPriorityCandidateIds = new Set(
|
||||
manualPriorityCandidates.map((participant) => participant.userId),
|
||||
);
|
||||
const selectedManualTopTierUserIds = manualTopTierUserIds.filter((userId) =>
|
||||
manualPriorityCandidateIds.has(userId),
|
||||
const selectedManualTopTierUserIds =
|
||||
manualTopTierAuctionPriorityUserIds.filter((userId) =>
|
||||
manualPriorityCandidateIds.has(userId),
|
||||
);
|
||||
const parsedMaxTimerSeconds = parseAuctionSecondsInput(
|
||||
maximumBidRoundDurationSecondsInput,
|
||||
5,
|
||||
);
|
||||
const parsedMaxTimerSeconds = parseAuctionSecondsInput(maxTimerSeconds, 5);
|
||||
const parsedBidExtensionSeconds = parseAuctionSecondsInput(
|
||||
bidExtensionSeconds,
|
||||
bidRoundExtensionSecondsInput,
|
||||
0,
|
||||
);
|
||||
const hasValidAuctionTimerSettings =
|
||||
@@ -2997,8 +3014,9 @@ export default function MatchDetailPage() {
|
||||
...current,
|
||||
[key]: {
|
||||
userId: event.target.value,
|
||||
initialPoints:
|
||||
current[key]?.initialPoints ??
|
||||
initialTeamBidPointAmountInput:
|
||||
current[key]
|
||||
?.initialTeamBidPointAmountInput ??
|
||||
"1000",
|
||||
},
|
||||
}))
|
||||
@@ -3035,28 +3053,34 @@ export default function MatchDetailPage() {
|
||||
step={50}
|
||||
className="w-full border border-base-content/10 bg-transparent px-2 py-2 text-sm tabular-nums"
|
||||
value={
|
||||
currentSelection?.initialPoints ?? "1000"
|
||||
currentSelection
|
||||
?.initialTeamBidPointAmountInput ??
|
||||
"1000"
|
||||
}
|
||||
onChange={(event) =>
|
||||
setCaptainSelections((current) => ({
|
||||
...current,
|
||||
[key]: {
|
||||
userId: current[key]?.userId ?? "",
|
||||
initialPoints: event.target.value,
|
||||
initialTeamBidPointAmountInput:
|
||||
event.target.value,
|
||||
},
|
||||
}))
|
||||
}
|
||||
onBlur={() =>
|
||||
setCaptainSelections((current) => {
|
||||
const points = parseInitialPointsInput(
|
||||
current[key]?.initialPoints ?? "",
|
||||
current[key]
|
||||
?.initialTeamBidPointAmountInput ??
|
||||
"",
|
||||
);
|
||||
if (points !== null) return current;
|
||||
return {
|
||||
...current,
|
||||
[key]: {
|
||||
userId: current[key]?.userId ?? "",
|
||||
initialPoints: "1000",
|
||||
initialTeamBidPointAmountInput:
|
||||
"1000",
|
||||
},
|
||||
};
|
||||
})
|
||||
@@ -3082,17 +3106,22 @@ export default function MatchDetailPage() {
|
||||
max={MAX_AUCTION_TIMER_SECONDS}
|
||||
step={5}
|
||||
className="min-w-0 flex-1 bg-transparent px-2 py-2 text-sm tabular-nums focus:outline-none"
|
||||
value={maxTimerSeconds}
|
||||
value={maximumBidRoundDurationSecondsInput}
|
||||
onChange={(event) =>
|
||||
setMaxTimerSeconds(event.target.value)
|
||||
setMaximumBidRoundDurationSecondsInput(
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
onBlur={() => {
|
||||
if (
|
||||
parseAuctionSecondsInput(maxTimerSeconds, 5)
|
||||
parseAuctionSecondsInput(
|
||||
maximumBidRoundDurationSecondsInput,
|
||||
5,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
setMaxTimerSeconds(
|
||||
setMaximumBidRoundDurationSecondsInput(
|
||||
String(DEFAULT_AUCTION_MAX_TIMER_SECONDS),
|
||||
);
|
||||
}}
|
||||
@@ -3111,20 +3140,22 @@ export default function MatchDetailPage() {
|
||||
max={MAX_AUCTION_TIMER_SECONDS}
|
||||
step={1}
|
||||
className="min-w-0 flex-1 bg-transparent px-2 py-2 text-sm tabular-nums focus:outline-none"
|
||||
value={bidExtensionSeconds}
|
||||
value={bidRoundExtensionSecondsInput}
|
||||
onChange={(event) =>
|
||||
setBidExtensionSeconds(event.target.value)
|
||||
setBidRoundExtensionSecondsInput(
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
onBlur={() => {
|
||||
if (
|
||||
parseAuctionSecondsInput(
|
||||
bidExtensionSeconds,
|
||||
bidRoundExtensionSecondsInput,
|
||||
0,
|
||||
) !== null
|
||||
) {
|
||||
return;
|
||||
}
|
||||
setBidExtensionSeconds(
|
||||
setBidRoundExtensionSecondsInput(
|
||||
String(DEFAULT_AUCTION_BID_EXTENSION_SECONDS),
|
||||
);
|
||||
}}
|
||||
@@ -3142,9 +3173,9 @@ export default function MatchDetailPage() {
|
||||
상위 티어 우선 등장
|
||||
<select
|
||||
className="mt-1 h-[38px] w-full border border-base-content/10 bg-transparent px-2 py-2 text-sm focus:border-primary/30 focus:outline-none"
|
||||
value={topTierThreshold}
|
||||
value={topTierAuctionPriorityThreshold}
|
||||
onChange={(event) =>
|
||||
setTopTierThreshold(
|
||||
setTopTierAuctionPriorityThreshold(
|
||||
event.target.value as AuctionTopTierThreshold,
|
||||
)
|
||||
}
|
||||
@@ -3157,7 +3188,7 @@ export default function MatchDetailPage() {
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
{topTierThreshold === "MANUAL" && (
|
||||
{topTierAuctionPriorityThreshold === "MANUAL" && (
|
||||
<div className="border border-base-content/10 bg-base-200/20 p-3">
|
||||
<div className="mb-2 text-xs font-bold uppercase tracking-wider text-base-content/35">
|
||||
우선 등장 선수
|
||||
@@ -3193,18 +3224,19 @@ export default function MatchDetailPage() {
|
||||
className="checkbox checkbox-primary checkbox-xs"
|
||||
checked={checked}
|
||||
onChange={(event) =>
|
||||
setManualTopTierUserIds((current) =>
|
||||
event.target.checked
|
||||
? [
|
||||
...new Set([
|
||||
...current,
|
||||
participant.userId,
|
||||
]),
|
||||
]
|
||||
: current.filter(
|
||||
(userId) =>
|
||||
userId !== participant.userId,
|
||||
),
|
||||
setManualTopTierAuctionPriorityUserIds(
|
||||
(current) =>
|
||||
event.target.checked
|
||||
? [
|
||||
...new Set([
|
||||
...current,
|
||||
participant.userId,
|
||||
]),
|
||||
]
|
||||
: current.filter(
|
||||
(userId) =>
|
||||
userId !== participant.userId,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
@@ -3226,7 +3258,9 @@ export default function MatchDetailPage() {
|
||||
disabled={
|
||||
!canStartAuction || startAuctionMutation.isPending
|
||||
}
|
||||
onClick={() => startAuctionMutation.mutate()}
|
||||
onClick={() =>
|
||||
startAuctionMutation.mutate(crypto.randomUUID())
|
||||
}
|
||||
>
|
||||
{startAuctionMutation.isPending
|
||||
? "시작 중..."
|
||||
|
||||
Reference in new issue
Block a user