Work around caqti assertion failure

This commit is contained in:
Robur 2021-11-17 14:06:18 +00:00
parent c566cd0215
commit 8ee69d7211
3 changed files with 20 additions and 5 deletions

View file

@ -315,16 +315,26 @@ module Build = struct
ORDER BY start_d DESC, start_ps DESC ORDER BY start_d DESC, start_ps DESC
|} |}
(* XXX: caqti doesn't like this *)
let get_all_failed = let get_all_failed =
Caqti_request.collect Caqti_request.collect
Caqti_type.(option string) Caqti_type.unit
(Caqti_type.tup2 (id `build) t) (Caqti_type.tup2 (id `build) t)
{| SELECT id, uuid, start_d, start_ps, finish_d, finish_ps, {| SELECT id, uuid, start_d, start_ps, finish_d, finish_ps,
result_code, result_msg, console, script, platform, result_code, result_msg, console, script, platform,
main_binary, input_id, user, job main_binary, input_id, user, job
FROM build FROM build
WHERE ?1 IS NULL OR ?1 = build.platform 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 = ?
ORDER BY start_d DESC, start_ps DESC ORDER BY start_d DESC, start_ps DESC
|} |}

View file

@ -114,7 +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 :
(string option, [`build] id * t, [ `Many | `One | `Zero ]) Caqti_request.t (unit, [`build] id * t, [ `Many | `One | `Zero ]) Caqti_request.t
val get_all_failed_by_platform :
(string, [`build] id * 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,7 +82,10 @@ 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) =
Db.collect_list Builder_db.Build.get_all_failed platform >|= List.map snd (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
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 ->