mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Trying to make offset / limit consistent
This commit is contained in:
parent
4deaed1c78
commit
cc9364f37e
1 changed files with 11 additions and 12 deletions
|
@ -201,20 +201,16 @@ def app_list(offset=None, limit=None, filter=None, raw=False, installed=False, w
|
||||||
if not (len(app_dict) > (0 + offset) and limit > 0):
|
if not (len(app_dict) > (0 + offset) and limit > 0):
|
||||||
return {'apps': list_dict} if not raw else list_dict
|
return {'apps': list_dict} if not raw else list_dict
|
||||||
|
|
||||||
# Build dict taking account of offset (ordered with sorted)
|
# Sort app list
|
||||||
sorted_app_dict = {}
|
sorted_app_list = sorted(app_dict.keys())
|
||||||
print( sorted(app_dict.keys())[offset:])
|
|
||||||
for sorted_keys in sorted(app_dict.keys())[offset:]:
|
# Take into account offset
|
||||||
sorted_app_dict[sorted_keys] = app_dict[sorted_keys]
|
sorted_app_list = sorted_app_list[offset:]
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
for app_id, app_info_dict in sorted_app_dict.items():
|
for app_id in sorted_app_list:
|
||||||
|
|
||||||
print(app_id)
|
app_info_dict = app_dict[app_id]
|
||||||
|
|
||||||
# Apply limit
|
|
||||||
if i >= limit:
|
|
||||||
break
|
|
||||||
|
|
||||||
# Apply filter if there's one
|
# Apply filter if there's one
|
||||||
if (filter and
|
if (filter and
|
||||||
|
@ -262,7 +258,10 @@ def app_list(offset=None, limit=None, filter=None, raw=False, installed=False, w
|
||||||
'installed': app_installed
|
'installed': app_installed
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Count listed apps and apply limit
|
||||||
i += 1
|
i += 1
|
||||||
|
if i >= limit:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
return {'apps': list_dict} if not raw else list_dict
|
return {'apps': list_dict} if not raw else list_dict
|
||||||
|
|
Loading…
Add table
Reference in a new issue