Skip to content

Commit db9c850

Browse files
author
dudina-ma
committed
[task/add] address review comments
1 parent bab9152 commit db9c850

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

frontend/src/lib/api/projects.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,21 @@ export function listProjects(limit = 20, offset = 0, search?: string): Promise<P
77
return apiRequest<PaginatedResponse<Project>>('GET', `/projects?${params}`)
88
}
99

10+
const LIST_ALL_PROJECTS_MAX_PAGES = 100
11+
1012
export async function listAllProjects(search?: string): Promise<Project[]> {
1113
const pageSize = 100
1214
const items: Project[] = []
1315
let offset = 0
1416
let total = Number.POSITIVE_INFINITY
17+
let pagesFetched = 0
1518

16-
while (offset < total) {
19+
while (offset < total && pagesFetched < LIST_ALL_PROJECTS_MAX_PAGES) {
1720
const page = await listProjects(pageSize, offset, search)
1821
items.push(...page.items)
1922
total = page.total
2023
offset += page.items.length
24+
pagesFetched++
2125
if (page.items.length === 0) break
2226
}
2327

0 commit comments

Comments
 (0)