Fix oxlint errors in QP Discord notification files
- Use import type for database (type-only usage) - Replace non-null assertions with type casts (qualifyingPointsAwarded as string) and optional chaining (?.ownerId, league narrowing via explicit check) - Eliminate Map.get()! after set() with if/else bucket pattern Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NnJP1NTYXHxL2kbE4fZaD6
This commit is contained in:
parent
aea71a5ad6
commit
e492db660b
2 changed files with 14 additions and 10 deletions
|
|
@ -448,7 +448,7 @@ export async function assignCs2EliminationQP(
|
||||||
const existingQPBySPId = new Map<string, number>(
|
const existingQPBySPId = new Map<string, number>(
|
||||||
existingRows
|
existingRows
|
||||||
.filter((r) => r.qualifyingPointsAwarded !== null)
|
.filter((r) => r.qualifyingPointsAwarded !== null)
|
||||||
.map((r) => [r.seasonParticipantId, parseFloat(r.qualifyingPointsAwarded!)])
|
.map((r) => [r.seasonParticipantId, parseFloat(r.qualifyingPointsAwarded as string)])
|
||||||
);
|
);
|
||||||
|
|
||||||
await writeEventResultsQP(scoringEventId, sportsSeasonId, resultsByParticipant, db);
|
await writeEventResultsQP(scoringEventId, sportsSeasonId, resultsByParticipant, db);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { database } from "~/database/context";
|
import type { database } from "~/database/context";
|
||||||
import * as schema from "~/database/schema";
|
import * as schema from "~/database/schema";
|
||||||
import { eq, inArray } from "drizzle-orm";
|
import { eq, inArray } from "drizzle-orm";
|
||||||
import { findDiscordIdsByUserIds } from "~/models/account";
|
import { findDiscordIdsByUserIds } from "~/models/account";
|
||||||
|
|
@ -40,7 +40,7 @@ export async function notifyQualifyingPointsUpdate(
|
||||||
eventResultRows
|
eventResultRows
|
||||||
.filter((r) => r.qualifyingPointsAwarded !== null)
|
.filter((r) => r.qualifyingPointsAwarded !== null)
|
||||||
.filter((r) => !participantIdFilter || participantIdFilter.has(r.seasonParticipantId))
|
.filter((r) => !participantIdFilter || participantIdFilter.has(r.seasonParticipantId))
|
||||||
.map((r) => [r.seasonParticipantId, parseFloat(r.qualifyingPointsAwarded!)])
|
.map((r) => [r.seasonParticipantId, parseFloat(r.qualifyingPointsAwarded as string)])
|
||||||
);
|
);
|
||||||
|
|
||||||
if (qpEarnedById.size === 0) return;
|
if (qpEarnedById.size === 0) return;
|
||||||
|
|
@ -69,8 +69,12 @@ export async function notifyQualifyingPointsUpdate(
|
||||||
});
|
});
|
||||||
const picksBySeasonId = new Map<string, (typeof allPicks)[number][]>();
|
const picksBySeasonId = new Map<string, (typeof allPicks)[number][]>();
|
||||||
for (const pick of allPicks) {
|
for (const pick of allPicks) {
|
||||||
if (!picksBySeasonId.has(pick.seasonId)) picksBySeasonId.set(pick.seasonId, []);
|
const bucket = picksBySeasonId.get(pick.seasonId);
|
||||||
picksBySeasonId.get(pick.seasonId)!.push(pick);
|
if (bucket) {
|
||||||
|
bucket.push(pick);
|
||||||
|
} else {
|
||||||
|
picksBySeasonId.set(pick.seasonId, [pick]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Batch-fetch participant display names once (same participants across all leagues)
|
// Batch-fetch participant display names once (same participants across all leagues)
|
||||||
|
|
@ -99,10 +103,11 @@ export async function notifyQualifyingPointsUpdate(
|
||||||
|
|
||||||
for (const { seasonId } of seasonSports) {
|
for (const { seasonId } of seasonSports) {
|
||||||
const season = seasonMap.get(seasonId);
|
const season = seasonMap.get(seasonId);
|
||||||
const webhookUrl = season?.league?.discordWebhookUrl;
|
const league = season?.league;
|
||||||
if (!webhookUrl) continue;
|
const webhookUrl = league?.discordWebhookUrl;
|
||||||
|
if (!webhookUrl || !season || !league) continue;
|
||||||
|
|
||||||
const seasonName = `${season!.league!.name} ${season!.year}`;
|
const seasonName = `${league.name} ${season.year}`;
|
||||||
|
|
||||||
const picks = picksBySeasonId.get(seasonId) ?? [];
|
const picks = picksBySeasonId.get(seasonId) ?? [];
|
||||||
const teamByParticipantId = new Map<
|
const teamByParticipantId = new Map<
|
||||||
|
|
@ -123,8 +128,7 @@ export async function notifyQualifyingPointsUpdate(
|
||||||
if (relevantParticipantIds.length === 0) continue;
|
if (relevantParticipantIds.length === 0) continue;
|
||||||
|
|
||||||
const entries: QPEventEntry[] = relevantParticipantIds.map((participantId) => {
|
const entries: QPEventEntry[] = relevantParticipantIds.map((participantId) => {
|
||||||
const teamInfo = teamByParticipantId.get(participantId)!;
|
const ownerId = teamByParticipantId.get(participantId)?.ownerId ?? null;
|
||||||
const ownerId = teamInfo.ownerId;
|
|
||||||
return {
|
return {
|
||||||
participantName: participantNameById.get(participantId) ?? participantId,
|
participantName: participantNameById.get(participantId) ?? participantId,
|
||||||
qpEarned: qpEarnedById.get(participantId) ?? 0,
|
qpEarned: qpEarnedById.get(participantId) ?? 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue