Просмотр исходного кода

fix: update weekly date condition in leaderboard query

- Changed the weekly date condition to use date_trunc for better accuracy in determining the current week.
ding113 2 месяцев назад
Родитель
Сommit
f6271e89ad
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      src/repository/leaderboard.ts

+ 1 - 1
src/repository/leaderboard.ts

@@ -109,7 +109,7 @@ function buildDateCondition(
     case "daily":
       return sql`(${messageRequest.createdAt} AT TIME ZONE ${timezone})::date = (CURRENT_TIMESTAMP AT TIME ZONE ${timezone})::date`;
     case "weekly":
-      return sql`(${messageRequest.createdAt} AT TIME ZONE ${timezone})::date >= (CURRENT_DATE AT TIME ZONE ${timezone} - INTERVAL '6 days')`;
+      return sql`date_trunc('week', ${messageRequest.createdAt} AT TIME ZONE ${timezone}) = date_trunc('week', CURRENT_TIMESTAMP AT TIME ZONE ${timezone})`;
     case "monthly":
       return sql`date_trunc('month', ${messageRequest.createdAt} AT TIME ZONE ${timezone}) = date_trunc('month', CURRENT_TIMESTAMP AT TIME ZONE ${timezone})`;
     default: