Workforce: fetch locations to resolve location names on departments
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5d6a9ea3cd
commit
9ea567955d
2 changed files with 12 additions and 6 deletions
|
|
@ -36,7 +36,7 @@ async function wfFetchPaged(path) {
|
|||
while (true) {
|
||||
const sep = path.includes('?') ? '&' : '?'
|
||||
const data = await wfFetch(`${path}${sep}page=${page}&page_size=100`)
|
||||
const items = Array.isArray(data) ? data : (data.users ?? data.departments ?? data.teams ?? [])
|
||||
const items = Array.isArray(data) ? data : (data.users ?? data.departments ?? data.teams ?? data.locations ?? [])
|
||||
results.push(...items)
|
||||
if (items.length < 100) break
|
||||
page++
|
||||
|
|
@ -59,6 +59,10 @@ export async function findEmployeeById(wfUserId) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function getAllLocations() {
|
||||
return wfFetchPaged('/api/v2/locations')
|
||||
}
|
||||
|
||||
export async function getAllDepartments() {
|
||||
return wfFetchPaged('/api/v2/departments')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue