Get stats command to console log the current users stats

This commit is contained in:
Dominic Ferrando
2026-08-15 16:59:50 -04:00
parent a4e7060538
commit 4d7581620f
3 changed files with 19 additions and 8 deletions
+7 -5
View File
@@ -70,9 +70,11 @@ async function seedCalculator(standardsConfigId: string): Promise<void> {
}
async function seedAccounts(): Promise<void> {
const ACCOUNT_NAME = "Xominus";
const existing = await db.selectFrom("accounts")
.select(["id"])
.where("name", "=", DEFAULT_NAME)
.where("name", "=", ACCOUNT_NAME)
.executeTakeFirst();
if (existing) {
log.info({ id: existing.id }, "default account already seeded, skipping");
@@ -81,9 +83,9 @@ async function seedAccounts(): Promise<void> {
const account = await db.insertInto("accounts")
.values({
name: DEFAULT_NAME,
discord_id: "1521640671721685157",
email: "outgrow_document040@simplelogin.com"
name: ACCOUNT_NAME,
discord_id: "1325552430942916731",
email: "xominus@bladeandbrawn.com"
})
.returning("id")
.executeTakeFirstOrThrow();
@@ -92,7 +94,7 @@ async function seedAccounts(): Promise<void> {
await db.insertInto("assessments")
.values({
account_id: account.id,
name: DEFAULT_NAME,
name: ACCOUNT_NAME,
gender: Gender.Male,
age: 25,
weight: 80,
+8 -2
View File
@@ -7,10 +7,16 @@ import { t } from "elysia";
export class AccountsService {
constructor(private Calculator: CalculatorService) { }
private static idComparison(id: string): ["accounts.id" | "accounts.discord_id", "=", string] {
return id.startsWith("@")
? ["accounts.discord_id", "=", id.slice(1)]
: ["accounts.id", "=", id];
}
async get(id: string) {
return await (db).selectFrom("accounts")
.selectAll()
.where("id", "=", id)
.where(...AccountsService.idComparison(id))
.executeTakeFirst();
}
@@ -22,7 +28,7 @@ export class AccountsService {
"assessments.perf_back_squat", "assessments.perf_bench_press", "assessments.perf_broad_jump",
"assessments.perf_cone_drill", "assessments.perf_deadlift", "assessments.perf_run"
])
.where("accounts.id", "=", id)
.where(...AccountsService.idComparison(id))
.orderBy("assessments.created_at", "desc")
.limit(1)
.executeTakeFirst();