From 284bdf312384ad4f1b1d4b97e4f7a734c0a163b2 Mon Sep 17 00:00:00 2001 From: JacobLinCool Date: Tue, 30 May 2023 20:49:00 +0800 Subject: [PATCH] feat: more column in admin scoreboard --- src/routes/admin/scoreboard/+page.server.ts | 9 ++++++- src/routes/admin/scoreboard/+page.svelte | 29 +++++++++++++++++++++ src/routes/api/object/[file]/+server.ts | 4 +-- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/routes/admin/scoreboard/+page.server.ts b/src/routes/admin/scoreboard/+page.server.ts index 8a4ea56..c540f7c 100644 --- a/src/routes/admin/scoreboard/+page.server.ts +++ b/src/routes/admin/scoreboard/+page.server.ts @@ -27,7 +27,10 @@ export const load: PageServerLoad = async ({ locals, platform }) => { const q1 = db .selectFrom("Voting") .innerJoin("Profile", "Profile.email", "Voting.target") - .groupBy("Voting.target") + .leftJoin("Application", "Profile.email", "Application.email") + .leftJoin("Payment", "Profile.email", "Payment.email") + .leftJoin("Attachment", "Profile.email", "Attachment.email") + .groupBy(["Voting.target"]) .select([ "Profile.name", "Profile.school", @@ -42,6 +45,10 @@ export const load: PageServerLoad = async ({ locals, platform }) => { "Profile.skill_experienced", "Profile.skill_mastered", (b) => b.fn.sum("vote").as("score"), + "Application.status", + "Payment.account", + "Payment.time as pay_date", + "Attachment.file", ]) .orderBy("score", "desc"); diff --git a/src/routes/admin/scoreboard/+page.svelte b/src/routes/admin/scoreboard/+page.svelte index 1cc44f5..99f02aa 100644 --- a/src/routes/admin/scoreboard/+page.svelte +++ b/src/routes/admin/scoreboard/+page.svelte @@ -32,6 +32,9 @@ 食物 衣服 分數 + 狀態 + 繳費 + 同意書 @@ -60,6 +63,32 @@ {app.food_type} {app.clothes_size} {app.score} + + {app.status || "放棄 QQ"} + + + {#if app.account && app.pay_date} + {app.account} ({app.pay_date}) + {:else} + 無 + {/if} + + + {#if app.file} + + {app.file} + + {:else} + 無 + {/if} + {/await} {/each} diff --git a/src/routes/api/object/[file]/+server.ts b/src/routes/api/object/[file]/+server.ts index b2eef66..a2b8d41 100644 --- a/src/routes/api/object/[file]/+server.ts +++ b/src/routes/api/object/[file]/+server.ts @@ -73,10 +73,10 @@ export const PUT: RequestHandler = async ({ locals, params, request, platform }) if (file === "profile.jpg") { await complete("avatar", locals.token.email, platform); + } else { + await uploaded(platform, locals.token.email, file); } - await uploaded(platform, locals.token.email, file); - return json({ ok: true }); };