Skip to content

Commit 200eeb2

Browse files
committed
feat : 검색 로그 집계를 최근 15일로 제한 (#244)
1 parent 256d98c commit 200eeb2

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

apps/web/src/app/api/search/log/route.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { subDays } from 'date-fns';
12
import { NextResponse } from 'next/server';
23

34
import createClient from '@/lib/supabase/server';
@@ -11,7 +12,13 @@ interface SearchLogCount {
1112
export async function GET(): Promise<NextResponse<ApiResponse<SearchLogCount[]>>> {
1213
try {
1314
const supabase = await createClient();
14-
const { data, error } = await supabase.from('search_logs').select('text');
15+
16+
// 최근 15일간의 검색 로그만 집계
17+
const fifteenDaysAgo = subDays(new Date(), 15).toISOString();
18+
const { data, error } = await supabase
19+
.from('search_logs')
20+
.select('text')
21+
.gte('created_at', fifteenDaysAgo);
1522

1623
if (error) throw error;
1724

0 commit comments

Comments
 (0)