Skip to content

Commit

Permalink
fix(leaderboard): change range into last 6 months
Browse files Browse the repository at this point in the history
  • Loading branch information
tfkhdyt committed Jul 7, 2024
1 parent 3c33b8c commit fb863c3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/server/api/routers/subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const subjectRouter = createTRPCRouter({
.leftJoin(favorites, eq(favorites.questionId, questions.id))
.where(
and(
gt(questions.createdAt, dayjs().subtract(7, 'days').toDate()),
gt(answers.createdAt, dayjs().subtract(7, 'days').toDate()),
gt(questions.createdAt, dayjs().subtract(6, 'months').toDate()),
gt(answers.createdAt, dayjs().subtract(6, 'months').toDate()),
),
)
.orderBy(desc(score))
Expand Down
4 changes: 2 additions & 2 deletions src/server/api/routers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ export const userRouter = createTRPCRouter({
.leftJoin(favorites, eq(favorites.userId, users.id))
.where(
and(
gt(questions.createdAt, dayjs().subtract(7, 'days').toDate()),
gt(answers.createdAt, dayjs().subtract(7, 'days').toDate()),
gt(questions.createdAt, dayjs().subtract(6, 'months').toDate()),
gt(answers.createdAt, dayjs().subtract(6, 'months').toDate()),
),
)
.groupBy(users.id)
Expand Down
4 changes: 2 additions & 2 deletions src/server/repositories/postgres/question-repo-pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ class QuestionRepoPg {
subjectId
? and(
eq(questions.subjectId, subjectId),
gt(questions.createdAt, dayjs().subtract(7, 'days').toDate()),
gt(questions.createdAt, dayjs().subtract(6, 'months').toDate()),
)
: gt(questions.createdAt, dayjs().subtract(7, 'days').toDate()),
: gt(questions.createdAt, dayjs().subtract(6, 'months').toDate()),
)
.orderBy(desc(popularity))
.groupBy(
Expand Down

0 comments on commit fb863c3

Please sign in to comment.