fix(don): fix top sql, again, again, for podium
Build and Push Image / build-backend (push) Successful in 20s
Build and Push Image / build-frontend (push) Successful in 1m28s
Build and Push Image / push (push) Successful in 48s

This commit is contained in:
2026-06-11 00:20:37 +07:00 Unverified
parent 4f3c65ab9c
commit a9e9d3e4d0
2 changed files with 26 additions and 19 deletions
+25 -18
View File
@@ -55,24 +55,31 @@ async function Content() {
.orderBy(desc(sum(donations.amount)), asc(max(donations.id)));
const podium = await db
.select({
name: donations.name,
amount: donations.amount,
image: donations.image,
})
.from(donations)
.limit(3)
.orderBy(desc(donations.amount), asc(donations.id))
.then((r) =>
Promise.all(
r.map(async (d) => ({
...d,
image: d.image
? await fileToDataUrl(new File([Buffer.from(d.image)], "image.jpg"))
: undefined,
})),
),
);
.select({
name: donations.name,
amount: sum(donations.amount).as("amount"),
image: sql<Buffer | null>`
(
array_agg(${donations.image}
ORDER BY ${donations.id} DESC
)
)[1]
`,
})
.from(donations)
.groupBy(donations.name)
.orderBy(desc(sum(donations.amount)), asc(max(donations.id)))
.limit(3)
.then((r) =>
Promise.all(
r.map(async (d) => ({
...d,
image: d.image
? await fileToDataUrl(new File([Buffer.from(d.image)], "image.jpg"))
: undefined,
})),
),
);
return (
<div className="flex min-h-svh flex-col justify-center">
+1 -1
View File
@@ -27,7 +27,7 @@ const styles = [
interface TopDonateRow {
name: string;
amount: number;
amount: string | null;
image?: string;
}