-
Notifications
You must be signed in to change notification settings - Fork 0
Optimize frontend data fetching with parallelization #274
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 |
|---|---|---|
|
|
@@ -199,3 +199,4 @@ static/uploads/ | |
|
|
||
| # custom | ||
| AGENTS.md | ||
| tmp/* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import { | |
| } from '@/components/ui/select'; | ||
| import { Clock, Search, FolderOpen, AlertCircle } from 'lucide-react'; | ||
| import { projectsApi, tasksApi } from '@/lib/api'; | ||
| import { log } from '@/lib/logger'; | ||
| import type { Project } from '@/types/project'; | ||
|
|
||
| interface ManualTaskSelectDialogProps { | ||
|
|
@@ -63,12 +64,25 @@ export function ManualTaskSelectDialog({ | |
| queryKey: ['tasks', 'manual-select', selectedProjectId, projects.map(p => p.id).join(',')], | ||
| queryFn: async () => { | ||
| if (selectedProjectId === 'all') { | ||
| // Fetch tasks from all projects in parallel using Promise.all | ||
| // Fetch tasks from all projects in parallel. | ||
| // Ignore failures for individual projects and return other projects' tasks. | ||
| const taskPromises = projects.map((project) => | ||
| tasksApi.getByProject(project.id, 0, 100) | ||
| ); | ||
| const taskResults = await Promise.all(taskPromises); | ||
| return taskResults.flat(); | ||
| const taskResults = await Promise.allSettled(taskPromises); | ||
| return taskResults.flatMap((result, index) => { | ||
| if (result.status === 'fulfilled') { | ||
| return result.value; | ||
| } | ||
|
|
||
| log.error( | ||
| `Failed to load tasks for project ${projects[index]?.id}`, | ||
| result.reason instanceof Error ? result.reason : new Error(String(result.reason)), | ||
| { component: 'ManualTaskSelectDialog' } | ||
| ); | ||
|
Comment on lines
69
to
+82
|
||
|
|
||
| return []; | ||
| }); | ||
| } else { | ||
| return tasksApi.getByProject(selectedProjectId, 0, 100); | ||
| } | ||
|
|
||
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.
The per-project failure log uses
projects[index]?.id, which can become inaccurate if theprojectsstate changes between starting the requests and handling the settled results. Capture the project id alongside each promise (or close overproject.id) and use that captured id for error logs to ensure correct attribution.