bug534:アプリ最大100件超える場合の対応
This commit is contained in:
@@ -517,20 +517,17 @@ async def allapps(request:Request,c:config.KINTONE_ENV=Depends(getkintoneenv)):
|
|||||||
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
|
headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE}
|
||||||
url = f"{c.BASE_URL}{config.API_V1_STR}/apps.json"
|
url = f"{c.BASE_URL}{config.API_V1_STR}/apps.json"
|
||||||
offset = 0
|
offset = 0
|
||||||
|
limit = 100
|
||||||
all_apps = []
|
all_apps = []
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
r = httpx.get(f"{url}?limit=100&offset={offset}", headers=headers)
|
r = httpx.get(f"{url}?limit={limit}&offset={offset}", headers=headers)
|
||||||
json_data = r.json()
|
json_data = r.json()
|
||||||
if "apps" in json_data:
|
apps = json_data.get("apps",[])
|
||||||
all_apps.extend(json_data["apps"])
|
all_apps.extend(apps)
|
||||||
if len(json_data["apps"]) == 100:
|
if len(apps)<limit:
|
||||||
offset += 100
|
break;
|
||||||
else:
|
offset += 100
|
||||||
break
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
|
|
||||||
return {"apps": all_apps}
|
return {"apps": all_apps}
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user