-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 서버 집계 함수에 goalIds 필터 추가 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,14 +19,25 @@ const toProgressPercent = (completedCount: number, todoCount: number): number => | |||||
| return Math.round((completedCount / todoCount) * 100); | ||||||
| }; | ||||||
|
|
||||||
| export const getDashboardDetailTodos = async (): Promise<DashboardDetailTodosResult> => { | ||||||
| const normalizeGoalIds = (goalIds?: number[]): number[] => { | ||||||
| if (!goalIds) return []; | ||||||
| return [...new Set(goalIds.filter((id) => Number.isInteger(id) && id > 0))]; | ||||||
| }; | ||||||
|
|
||||||
| export const getDashboardDetailTodos = async (goalIds?: number[]): Promise<DashboardDetailTodosResult> => { | ||||||
| const targetGoalIds = normalizeGoalIds(goalIds); | ||||||
| const targetGoalIdSet = new Set(targetGoalIds); | ||||||
| const todoFetchLimit = Math.max(SAFE_LIMIT * Math.max(targetGoalIds.length, 1), SAFE_LIMIT * 5); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
|
|
||||||
| const [goalsRes, openTodosRes, doneTodosRes] = await Promise.allSettled([ | ||||||
| fetchGoals.getGoals(), | ||||||
| fetchTodos.getTodos({ sort: 'LATEST', search: '', limit: 300, done: false }), | ||||||
| fetchTodos.getTodos({ sort: 'LATEST', search: '', limit: 300, done: true }), | ||||||
| fetchGoals.getGoals({ limit: Math.max(targetGoalIds.length, 50) }), | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| fetchTodos.getTodos({ sort: 'LATEST', search: '', limit: todoFetchLimit, done: false }), | ||||||
| fetchTodos.getTodos({ sort: 'LATEST', search: '', limit: todoFetchLimit, done: true }), | ||||||
| ]); | ||||||
|
|
||||||
| const goals = goalsRes.status === 'fulfilled' ? goalsRes.value.goals : []; | ||||||
| const allGoals = goalsRes.status === 'fulfilled' ? goalsRes.value.goals : []; | ||||||
| const goals = | ||||||
| targetGoalIds.length > 0 ? allGoals.filter((goal) => targetGoalIdSet.has(goal.id)) : allGoals; | ||||||
| const openTodos = openTodosRes.status === 'fulfilled' ? openTodosRes.value.todos : []; | ||||||
| const doneTodos = doneTodosRes.status === 'fulfilled' ? doneTodosRes.value.todos : []; | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goalQueries.list호출 시limit: 100으로 하드코딩되어 있습니다. 사용자의 목표(Goal) 개수가 100개를 초과할 경우 일부 목표가 대시보드에 표시되지 않을 수 있습니다. 시스템의 최대 목표 생성 제한이 없다면, 페이지네이션을 도입하거나 충분히 큰 값을 사용하도록 검토가 필요합니다.