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))); .orderBy(desc(sum(donations.amount)), asc(max(donations.id)));
const podium = await db const podium = await db
.select({ .select({
name: donations.name, name: donations.name,
amount: donations.amount, amount: sum(donations.amount).as("amount"),
image: donations.image, image: sql<Buffer | null>`
}) (
.from(donations) array_agg(${donations.image}
.limit(3) ORDER BY ${donations.id} DESC
.orderBy(desc(donations.amount), asc(donations.id)) )
.then((r) => )[1]
Promise.all( `,
r.map(async (d) => ({ })
...d, .from(donations)
image: d.image .groupBy(donations.name)
? await fileToDataUrl(new File([Buffer.from(d.image)], "image.jpg")) .orderBy(desc(sum(donations.amount)), asc(max(donations.id)))
: undefined, .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 ( return (
<div className="flex min-h-svh flex-col justify-center"> <div className="flex min-h-svh flex-col justify-center">
+1 -1
View File
@@ -27,7 +27,7 @@ const styles = [
interface TopDonateRow { interface TopDonateRow {
name: string; name: string;
amount: number; amount: string | null;
image?: string; image?: string;
} }