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

View file

@ -114,9 +114,9 @@ sig
val get_all : val get_all :
([`job] id, [`build] id * t, [ `Many | `One | `Zero ]) Caqti_request.t ([`job] id, [`build] id * t, [ `Many | `One | `Zero ]) Caqti_request.t
val get_all_failed : 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 : 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 : val get_all_artifact_sha :
([`job] id, Cstruct.t, [ `Many | `One | `Zero ]) Caqti_request.t ([`job] id, Cstruct.t, [ `Many | `One | `Zero ]) Caqti_request.t
val get_all_artifact_sha_by_platform : 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 Db.find_opt Builder_db.Build.get_next_successful_uuid id
let failed_builds platform (module Db : CONN) = let failed_builds platform (module Db : CONN) =
(match platform with match platform with
| None -> Db.collect_list Builder_db.Build.get_all_failed () | None -> Db.collect_list Builder_db.Build.get_all_failed ()
| Some p -> Db.collect_list Builder_db.Build.get_all_failed_by_platform p) | Some p -> Db.collect_list Builder_db.Build.get_all_failed_by_platform p
>|= List.map snd
let builds_with_different_input_and_same_main_binary id (module Db : CONN) = 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 -> 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 (Uuidm.t option, [> Caqti_error.call_or_retrieve ]) result Lwt.t
val failed_builds : string option -> Caqti_lwt.connection -> 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 -> 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 (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 " "; txt " ";
a ~a:[Fmt.kstr a_href "job/%s/build/%a/" job_name Uuidm.pp a ~a:[Fmt.kstr a_href "job/%s/build/%a/" job_name Uuidm.pp
latest_build.Builder_db.Build.uuid] 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 " "; txt " ";
] @ (match latest_artifact with ] @ (match latest_artifact with
| Some main_binary -> | Some main_binary ->
@ -495,9 +495,13 @@ let compare_builds job_left job_right
]) ])
let failed_builds builds = let failed_builds builds =
let build build = let build (job_name, build) =
let _ = build in li [
li [txt "build info here"] 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 in
layout ~title:"Failed builds" layout ~title:"Failed builds"
([ h1 [txt "Failed builds"]; ([ h1 [txt "Failed builds"];