Skip to content

Commit bda2d2d

Browse files
authored
Sort posts in user page (#90)
* sort answers in user page * remove post.createdAt' --------- Co-authored-by: Anay Parswani <[email protected]>
1 parent b8d31c4 commit bda2d2d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

apps/web/app/user/[discordID]/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { getCanonicalUserUrl } from '@/utils/urls'
66
import { Metadata } from 'next'
77
import { db, sql } from '@nextjs-forum/db/node'
88
import { notFound } from 'next/navigation'
9+
10+
export const revalidate = 60
11+
export const dynamic = 'error'
12+
913
const getLeaderboardPosition = async (discordID: string) => {
1014
const result = await db
1115
.with('rankedUsers', (db) =>
@@ -54,8 +58,9 @@ const getUserPosts = async (discordID: string) => {
5458
const posts = await db
5559
.selectFrom('posts')
5660
.innerJoin('messages', 'posts.answerId', 'messages.snowflakeId')
57-
.select(['posts.id']) // Select more as needed
61+
.select(['posts.id'])
5862
.where('messages.userId', '=', discordID)
63+
.orderBy('posts.createdAt', 'desc')
5964
.limit(5)
6065
.execute()
6166

@@ -86,6 +91,7 @@ const getUserPosts = async (discordID: string) => {
8691
.where('messages.snowflakeId', '!=', eb.ref('posts.snowflakeId'))
8792
.as('messagesCount') as any, // Ensure the return type matches AliasedSelectQueryBuilder
8893
])
94+
.orderBy('posts.createdAt', 'desc')
8995
.execute()
9096

9197
return detailedPosts

apps/web/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
/// <reference types="next/navigation-types/compat/navigation" />
44

55
// NOTE: This file should not be edited
6-
// see https://nextjs.org/docs/basic-features/typescript for more information.
6+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.

0 commit comments

Comments
 (0)