fix(don): fix top sql, again, again, for podium
This commit is contained in:
@@ -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">
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const styles = [
|
|||||||
|
|
||||||
interface TopDonateRow {
|
interface TopDonateRow {
|
||||||
name: string;
|
name: string;
|
||||||
amount: number;
|
amount: string | null;
|
||||||
image?: string;
|
image?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user