Skip to content

Commit

Permalink
feat: more column in admin scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobLinCool committed May 30, 2023
1 parent 3683dae commit 284bdf3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/routes/admin/scoreboard/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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");

Expand Down
29 changes: 29 additions & 0 deletions src/routes/admin/scoreboard/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<th>食物</th>
<th>衣服</th>
<th>分數</th>
<th>狀態</th>
<th>繳費</th>
<th>同意書</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -60,6 +63,32 @@
<td class="transition-all">{app.food_type}</td>
<td class="transition-all">{app.clothes_size}</td>
<td class="transition-all">{app.score}</td>
<td
class="transition-all"
class:text-error={!app.status}
class:text-success={app.status?.includes("錄取")}
>
{app.status || "放棄 QQ"}
</td>
<td
class="transition-all"
class:text-success={app.account && app.pay_date}
>
{#if app.account && app.pay_date}
{app.account} ({app.pay_date})
{:else}
{/if}
</td>
<td class="transition-all" class:text-success={app.file}>
{#if app.file}
<a href="/admin/file/{bucket}/consent.pdf" target="_blank">
{app.file}
</a>
{:else}
{/if}
</td>
</tr>
{/await}
{/each}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/api/object/[file]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
};

Expand Down

0 comments on commit 284bdf3

Please sign in to comment.