fixed matches fee calc
This commit is contained in:
+14
-10
@@ -18,7 +18,7 @@ import {
|
||||
type MatchmakerLogSource,
|
||||
} from "@/lib/matchmaker-log-source";
|
||||
import { readMatchmakerLogFile } from "@/lib/matchmaker-logs-server";
|
||||
import { fetchEntryHoldPerPlayerCoinsByMatchIds } from "@/lib/match-entry-hold-from-ledger";
|
||||
import { fetchMatchEntryHoldAndFeePerPlayerCoinsByMatchIds } from "@/lib/match-entry-hold-from-ledger";
|
||||
import type {
|
||||
AdminMatchRow,
|
||||
DbMatch,
|
||||
@@ -144,21 +144,25 @@ export default async function Home({
|
||||
matchesError = matchesRes.error.message;
|
||||
} else {
|
||||
const rawMatches = (matchesRes.data ?? []) as DbMatch[];
|
||||
const holdByMatch = await fetchEntryHoldPerPlayerCoinsByMatchIds(
|
||||
supabase,
|
||||
rawMatches
|
||||
.map((m) => Number(m.id))
|
||||
.filter((id) => Number.isFinite(id)),
|
||||
);
|
||||
const { holdPerPlayer, feePerPlayer } =
|
||||
await fetchMatchEntryHoldAndFeePerPlayerCoinsByMatchIds(
|
||||
supabase,
|
||||
rawMatches
|
||||
.map((m) => Number(m.id))
|
||||
.filter((id) => Number.isFinite(id)),
|
||||
);
|
||||
matches = rawMatches.map((m) => {
|
||||
const idNum = Number(m.id);
|
||||
const hold = Number.isFinite(idNum)
|
||||
? holdByMatch.get(idNum)
|
||||
: undefined;
|
||||
const hold =
|
||||
Number.isFinite(idNum) ? holdPerPlayer.get(idNum) : undefined;
|
||||
const fee =
|
||||
Number.isFinite(idNum) ? feePerPlayer.get(idNum) : undefined;
|
||||
return {
|
||||
...m,
|
||||
entryHoldPerPlayerCoins:
|
||||
hold !== undefined ? hold.toString() : null,
|
||||
entryFeePerPlayerCoins:
|
||||
fee !== undefined ? fee.toString() : null,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user