feat: logs api now also returns id
This commit is contained in:
parent
7b59277931
commit
210508f1ee
6 changed files with 19 additions and 13 deletions
|
|
@ -19,7 +19,7 @@ fn (mut app App) v1_get_logs() web.Result {
|
|||
}
|
||||
logs := app.db.get_build_logs(filter)
|
||||
|
||||
return app.json(http.Status.ok, new_data_response(logs))
|
||||
return app.json(.ok, new_data_response(logs))
|
||||
}
|
||||
|
||||
// v1_get_single_log returns the build log with the given id.
|
||||
|
|
@ -27,7 +27,7 @@ fn (mut app App) v1_get_logs() web.Result {
|
|||
fn (mut app App) v1_get_single_log(id int) web.Result {
|
||||
log := app.db.get_build_log(id) or { return app.not_found() }
|
||||
|
||||
return app.json(http.Status.ok, new_data_response(log))
|
||||
return app.json(.ok, new_data_response(log))
|
||||
}
|
||||
|
||||
// v1_get_log_content returns the actual build log file for the given id.
|
||||
|
|
@ -95,7 +95,8 @@ fn (mut app App) v1_post_log() web.Result {
|
|||
exit_code: exit_code
|
||||
}
|
||||
|
||||
app.db.add_build_log(log)
|
||||
// id of newly created log
|
||||
log_id := app.db.add_build_log(log)
|
||||
|
||||
repo_logs_dir := os.join_path(app.conf.data_dir, logs_dir_name, target_id.str(), arch)
|
||||
|
||||
|
|
@ -122,5 +123,5 @@ fn (mut app App) v1_post_log() web.Result {
|
|||
return app.status(http.Status.length_required)
|
||||
}
|
||||
|
||||
return app.json(http.Status.ok, new_response('Logs added successfully.'))
|
||||
return app.json(.ok, new_data_response(log_id))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ module server
|
|||
|
||||
import web
|
||||
import net.http
|
||||
import web.response { new_data_response, new_response, new_full_response }
|
||||
import web.response { new_data_response, new_response }
|
||||
import db
|
||||
import models { Target, TargetArch, TargetFilter }
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ fn (mut app App) v1_get_targets() web.Result {
|
|||
}
|
||||
repos := app.db.get_targets(filter)
|
||||
|
||||
return app.json(http.Status.ok, new_data_response(repos))
|
||||
return app.json(.ok, new_data_response(repos))
|
||||
}
|
||||
|
||||
// v1_get_single_target returns the information for a single target.
|
||||
|
|
@ -22,7 +22,7 @@ fn (mut app App) v1_get_targets() web.Result {
|
|||
fn (mut app App) v1_get_single_target(id int) web.Result {
|
||||
repo := app.db.get_target(id) or { return app.not_found() }
|
||||
|
||||
return app.json(http.Status.ok, new_data_response(repo))
|
||||
return app.json(.ok, new_data_response(repo))
|
||||
}
|
||||
|
||||
// v1_post_target creates a new target from the provided query string.
|
||||
|
|
@ -55,7 +55,7 @@ fn (mut app App) v1_post_target() web.Result {
|
|||
fn (mut app App) v1_delete_target(id int) web.Result {
|
||||
app.db.delete_target(id)
|
||||
|
||||
return app.json(http.Status.ok, new_response('Repo removed successfully.'))
|
||||
return app.status(.ok)
|
||||
}
|
||||
|
||||
// v1_patch_target updates a target's data with the given query params.
|
||||
|
|
@ -69,5 +69,5 @@ fn (mut app App) v1_patch_target(id int) web.Result {
|
|||
app.db.update_target_archs(id, arch_objs)
|
||||
}
|
||||
|
||||
return app.json(http.Status.ok, new_response('Repo updated successfully.'))
|
||||
return app.status(.ok)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue