feat: sort draft room and auto-pick by VORP instead of expected value
Update draft participant sorting to use vorpValue column instead of expectedValue in draft room initialization and auto-pick selection for both single-sport and multi-sport seasons. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3c740c50bf
commit
8ee5a8008e
2 changed files with 8 additions and 8 deletions
|
|
@ -283,12 +283,12 @@ export async function getTopAvailableParticipant(
|
||||||
allParticipants.push(...seasonParticipants);
|
allParticipants.push(...seasonParticipants);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort by EV desc, then name (expectedValue is a decimal string from DB)
|
// Sort by VORP desc, then name
|
||||||
allParticipants.sort((a, b) => {
|
allParticipants.sort((a, b) => {
|
||||||
const evA = parseFloat(String(a.expectedValue)) || 0;
|
const vorpA = parseFloat(String(a.vorpValue)) || 0;
|
||||||
const evB = parseFloat(String(b.expectedValue)) || 0;
|
const vorpB = parseFloat(String(b.vorpValue)) || 0;
|
||||||
if (evB !== evA) {
|
if (vorpB !== vorpA) {
|
||||||
return evB - evA;
|
return vorpB - vorpA;
|
||||||
}
|
}
|
||||||
return a.name.localeCompare(b.name);
|
return a.name.localeCompare(b.name);
|
||||||
});
|
});
|
||||||
|
|
@ -301,7 +301,7 @@ export async function getTopAvailableParticipant(
|
||||||
.select()
|
.select()
|
||||||
.from(schema.participants)
|
.from(schema.participants)
|
||||||
.where(eq(schema.participants.sportsSeasonId, sportsSeasonIds[0]))
|
.where(eq(schema.participants.sportsSeasonId, sportsSeasonIds[0]))
|
||||||
.orderBy(desc(schema.participants.expectedValue), schema.participants.name);
|
.orderBy(desc(schema.participants.vorpValue), schema.participants.name);
|
||||||
|
|
||||||
if (draftedIds.length > 0) {
|
if (draftedIds.length > 0) {
|
||||||
query = db
|
query = db
|
||||||
|
|
@ -313,7 +313,7 @@ export async function getTopAvailableParticipant(
|
||||||
notInArray(schema.participants.id, draftedIds)
|
notInArray(schema.participants.id, draftedIds)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.orderBy(desc(schema.participants.expectedValue), schema.participants.name);
|
.orderBy(desc(schema.participants.vorpValue), schema.participants.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [topParticipant] = await query;
|
const [topParticipant] = await query;
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ export async function loader(args: Route.LoaderArgs) {
|
||||||
: inArray(schema.participants.sportsSeasonId, sportsSeasonIds)
|
: inArray(schema.participants.sportsSeasonId, sportsSeasonIds)
|
||||||
)
|
)
|
||||||
.orderBy(
|
.orderBy(
|
||||||
desc(schema.participants.expectedValue),
|
desc(schema.participants.vorpValue),
|
||||||
asc(schema.participants.name)
|
asc(schema.participants.name)
|
||||||
)
|
)
|
||||||
: [];
|
: [];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue