bug534:アプリ最大100件超える場合の対応

This commit is contained in:
xiaozhe.ma
2024-07-22 18:00:03 +09:00
parent b9a7dd99da
commit e9eafdaf1a

View File

@@ -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}
url = f"{c.BASE_URL}{config.API_V1_STR}/apps.json"
offset = 0
limit = 100
all_apps = []
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()
if "apps" in json_data:
all_apps.extend(json_data["apps"])
if len(json_data["apps"]) == 100:
offset += 100
else:
break
else:
break
apps = json_data.get("apps",[])
all_apps.extend(apps)
if len(apps)<limit:
break;
offset += 100
return {"apps": all_apps}
except Exception as e: