Change to the new paging format with the commands available at the top.
This commit is contained in:
parent
dee6088b90
commit
6fd343741b
7 changed files with 213 additions and 140 deletions
|
@ -1184,10 +1184,31 @@ def get_repo_build_status(namespace, repository, build_uuid):
|
|||
def get_repo_build_logs(namespace, repository, build_uuid):
|
||||
permission = ModifyRepositoryPermission(namespace, repository)
|
||||
if permission.can():
|
||||
response_obj = {}
|
||||
|
||||
build = model.get_repository_build(namespace, repository, build_uuid)
|
||||
|
||||
start = int(request.args.get('start', -1000))
|
||||
start_param = request.args.get('start', None)
|
||||
end = int(request.args.get('end', -1))
|
||||
|
||||
last_command = None
|
||||
include_commands = request.args.get('commands', 'false')
|
||||
if include_commands.lower() not in {'0', 'false'}:
|
||||
commands = [cmd for cmd in build_logs.get_commands(build.uuid)]
|
||||
response_obj['commands'] = commands
|
||||
if commands:
|
||||
last_command = commands[-1]
|
||||
elif start_param is None:
|
||||
last_command = build_logs.get_last_command(build.uuid)
|
||||
|
||||
if start_param is None:
|
||||
if last_command:
|
||||
start = last_command['index']
|
||||
else:
|
||||
start = 0
|
||||
else:
|
||||
start = int(start_param)
|
||||
|
||||
count, logs = build_logs.get_log_entries(build.uuid, start, end)
|
||||
|
||||
if start < 0:
|
||||
|
@ -1196,13 +1217,15 @@ def get_repo_build_logs(namespace, repository, build_uuid):
|
|||
if end < 0:
|
||||
end = count + end
|
||||
|
||||
return jsonify({
|
||||
response_obj.update({
|
||||
'start': start,
|
||||
'end': end,
|
||||
'total': count,
|
||||
'logs': [log for log in logs],
|
||||
})
|
||||
|
||||
return jsonify(response_obj)
|
||||
|
||||
abort(403) # Permission denied
|
||||
|
||||
|
||||
|
|
Reference in a new issue