mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-20 02:08:33 -05:00
33 lines
560 B
TypeScript
33 lines
560 B
TypeScript
import { sql } from "~/db/sql";
|
|
import type { Tables } from "~/db/tables";
|
|
|
|
const stm = sql.prepare(/* sql */ `
|
|
select
|
|
"mu",
|
|
"sigma",
|
|
"matchesCount"
|
|
from
|
|
"Skill"
|
|
where
|
|
"id" = (
|
|
select max("id")
|
|
from "Skill"
|
|
where "userId" = @userId
|
|
and "season" = @season
|
|
group by "userId"
|
|
)
|
|
`);
|
|
|
|
export function findCurrentSkillByUserId({
|
|
userId,
|
|
season,
|
|
}: {
|
|
userId: number;
|
|
season: number;
|
|
}) {
|
|
return stm.get({ userId, season }) as Pick<
|
|
Tables["Skill"],
|
|
"mu" | "sigma" | "matchesCount"
|
|
> | null;
|
|
}
|