/failed-builds/: fix query and improve page

This commit is contained in:
Robur 2021-11-17 14:33:05 +00:00
parent 8ee69d7211
commit c6128ca24b
5 changed files with 28 additions and 22 deletions

View file

@ -318,23 +318,26 @@ module Build = struct
let get_all_failed =
Caqti_request.collect
Caqti_type.unit
(Caqti_type.tup2 (id `build) t)
{| SELECT id, uuid, start_d, start_ps, finish_d, finish_ps,
result_code, result_msg, console, script, platform,
main_binary, input_id, user, job
FROM build
(Caqti_type.tup2 Caqti_type.string t)
{| SELECT job.name, b.uuid, b.start_d, b.start_ps, b.finish_d, b.finish_ps,
b.result_code, b.result_msg, b.console, b.script, b.platform,
b.main_binary, b.input_id, b.user, b.job
FROM build b
INNER JOIN job ON job.id = b.job
WHERE b.result_code <> 0
ORDER BY start_d DESC, start_ps DESC
|}
let get_all_failed_by_platform =
Caqti_request.collect
Caqti_type.string
(Caqti_type.tup2 (id `build) t)
{| SELECT id, uuid, start_d, start_ps, finish_d, finish_ps,
result_code, result_msg, console, script, platform,
main_binary, input_id, user, job
FROM build
WHERE build.platform = ?
(Caqti_type.tup2 Caqti_type.string t)
{| SELECT job.name, b.id, b.uuid, b.start_d, b.start_ps, b.finish_d, b.finish_ps,
b.result_code, b.result_msg, b.console, b.script, b.platform,
b.main_binary, b.input_id, b.user, b.job
FROM build b
INNER JOIN job ON job.id = b.job
WHERE b.result_code <> 0 AND b.platform = ?
ORDER BY start_d DESC, start_ps DESC
|}

View file

@ -114,9 +114,9 @@ sig
val get_all :
([`job] id, [`build] id * t, [ `Many | `One | `Zero ]) Caqti_request.t
val get_all_failed :
(unit, [`build] id * t, [ `Many | `One | `Zero ]) Caqti_request.t
(unit, string * t, [ `Many | `One | `Zero ]) Caqti_request.t
val get_all_failed_by_platform :
(string, [`build] id * t, [ `Many | `One | `Zero ]) Caqti_request.t
(string, string * t, [ `Many | `One | `Zero ]) Caqti_request.t
val get_all_artifact_sha :
([`job] id, Cstruct.t, [ `Many | `One | `Zero ]) Caqti_request.t
val get_all_artifact_sha_by_platform :

View file

@ -82,10 +82,9 @@ let next_successful_build_uuid id (module Db : CONN) =
Db.find_opt Builder_db.Build.get_next_successful_uuid id
let failed_builds platform (module Db : CONN) =
(match platform with
match platform with
| None -> Db.collect_list Builder_db.Build.get_all_failed ()
| Some p -> Db.collect_list Builder_db.Build.get_all_failed_by_platform p)
>|= List.map snd
| Some p -> Db.collect_list Builder_db.Build.get_all_failed_by_platform p
let builds_with_different_input_and_same_main_binary id (module Db : CONN) =
Db.collect_list Builder_db.Build.get_different_input_same_output_input_ids id >>= fun ids ->

View file

@ -46,7 +46,7 @@ val next_successful_build_uuid : [`build] Builder_db.id -> Caqti_lwt.connection
(Uuidm.t option, [> Caqti_error.call_or_retrieve ]) result Lwt.t
val failed_builds : string option -> Caqti_lwt.connection ->
(Builder_db.Build.t list, [> Caqti_error.call_or_retrieve ]) result Lwt.t
((string * Builder_db.Build.t) list, [> Caqti_error.call_or_retrieve ]) result Lwt.t
val builds_with_different_input_and_same_main_binary : [`build] Builder_db.id -> Caqti_lwt.connection ->
(Builder_db.Build.t list, [> Caqti_error.call_or_retrieve ]) result Lwt.t

View file

@ -200,7 +200,7 @@ let builder section_job_map =
txt " ";
a ~a:[Fmt.kstr a_href "job/%s/build/%a/" job_name Uuidm.pp
latest_build.Builder_db.Build.uuid]
[txtf "%a" (Ptime.pp_human ()) latest_build.Builder_db.Build.start];
[txtf "%a" pp_ptime latest_build.Builder_db.Build.start];
txt " ";
] @ (match latest_artifact with
| Some main_binary ->
@ -495,9 +495,13 @@ let compare_builds job_left job_right
])
let failed_builds builds =
let build build =
let _ = build in
li [txt "build info here"]
let build (job_name, build) =
li [
txtf "%s %a " job_name pp_platform (Some build.Builder_db.Build.platform);
a ~a:[Fmt.kstr a_href "/job/%s/build/%a/" job_name Uuidm.pp build.uuid]
[txtf "%a" pp_ptime build.start];
txtf " %a" Builder.pp_execution_result build.result;
]
in
layout ~title:"Failed builds"
([ h1 [txt "Failed builds"];