link to failed-builds, paginate failed-builds
This commit is contained in:
parent
0910a05bbd
commit
e1d950ad5b
6 changed files with 35 additions and 15 deletions
|
@ -317,7 +317,7 @@ module Build = struct
|
||||||
|
|
||||||
let get_all_failed =
|
let get_all_failed =
|
||||||
Caqti_request.collect
|
Caqti_request.collect
|
||||||
Caqti_type.unit
|
Caqti_type.(tup2 int int)
|
||||||
(Caqti_type.tup2 Caqti_type.string t)
|
(Caqti_type.tup2 Caqti_type.string t)
|
||||||
{| SELECT job.name, b.uuid, b.start_d, b.start_ps, b.finish_d, b.finish_ps,
|
{| 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.result_code, b.result_msg, b.console, b.script, b.platform,
|
||||||
|
@ -326,19 +326,23 @@ module Build = struct
|
||||||
INNER JOIN job ON job.id = b.job
|
INNER JOIN job ON job.id = b.job
|
||||||
WHERE b.result_code <> 0
|
WHERE b.result_code <> 0
|
||||||
ORDER BY start_d DESC, start_ps DESC
|
ORDER BY start_d DESC, start_ps DESC
|
||||||
|
LIMIT ?2
|
||||||
|
OFFSET ?1
|
||||||
|}
|
|}
|
||||||
|
|
||||||
let get_all_failed_by_platform =
|
let get_all_failed_by_platform =
|
||||||
Caqti_request.collect
|
Caqti_request.collect
|
||||||
Caqti_type.string
|
Caqti_type.(tup3 int int string)
|
||||||
(Caqti_type.tup2 Caqti_type.string t)
|
(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,
|
{| 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.result_code, b.result_msg, b.console, b.script, b.platform,
|
||||||
b.main_binary, b.input_id, b.user, b.job
|
b.main_binary, b.input_id, b.user, b.job
|
||||||
FROM build b
|
FROM build b
|
||||||
INNER JOIN job ON job.id = b.job
|
INNER JOIN job ON job.id = b.job
|
||||||
WHERE b.result_code <> 0 AND b.platform = ?
|
WHERE b.result_code <> 0 AND b.platform = ?3
|
||||||
ORDER BY start_d DESC, start_ps DESC
|
ORDER BY start_d DESC, start_ps DESC
|
||||||
|
LIMIT ?2
|
||||||
|
OFFSET ?1
|
||||||
|}
|
|}
|
||||||
|
|
||||||
let get_all_artifact_sha =
|
let get_all_artifact_sha =
|
||||||
|
|
|
@ -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, string * t, [ `Many | `One | `Zero ]) Caqti_request.t
|
(int * int, string * t, [ `Many | `One | `Zero ]) Caqti_request.t
|
||||||
val get_all_failed_by_platform :
|
val get_all_failed_by_platform :
|
||||||
(string, string * t, [ `Many | `One | `Zero ]) Caqti_request.t
|
(int * int * 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 :
|
||||||
|
|
|
@ -232,11 +232,14 @@ let add_routes datadir =
|
||||||
|
|
||||||
let failed_builds req =
|
let failed_builds req =
|
||||||
let platform = Dream.query "platform" req in
|
let platform = Dream.query "platform" req in
|
||||||
Dream.sql req (Model.failed_builds platform)
|
let to_int default s = Option.(value ~default (bind s int_of_string_opt)) in
|
||||||
|
let start = to_int 0 (Dream.query "start" req) in
|
||||||
|
let count = to_int 10 (Dream.query "count" req) in
|
||||||
|
Dream.sql req (Model.failed_builds ~start ~count platform)
|
||||||
|> if_error "Error getting data"
|
|> if_error "Error getting data"
|
||||||
~log:(fun e -> Log.warn (fun m -> m "Error getting failed builds: %a"
|
~log:(fun e -> Log.warn (fun m -> m "Error getting failed builds: %a"
|
||||||
pp_error e)) >>= fun builds ->
|
pp_error e)) >>= fun builds ->
|
||||||
Views.failed_builds builds |> string_of_html |> Dream.html |> Lwt_result.ok
|
Views.failed_builds ~start ~count builds |> string_of_html |> Dream.html |> Lwt_result.ok
|
||||||
in
|
in
|
||||||
|
|
||||||
let upload req =
|
let upload req =
|
||||||
|
@ -364,8 +367,9 @@ let add_routes datadir =
|
||||||
let w f req = or_error_response (f req) in
|
let w f req = or_error_response (f req) in
|
||||||
|
|
||||||
(*
|
(*
|
||||||
/developer <- front page with failed builds (indication)
|
|
||||||
/job/:job/developer(?platform=XX) <- job list with failed builds
|
/job/:job/developer(?platform=XX) <- job list with failed builds
|
||||||
|
/job/:job/?platform=...&failed=true
|
||||||
|
/job/:job/failed(?platform=...)
|
||||||
*)
|
*)
|
||||||
|
|
||||||
Dream.router [
|
Dream.router [
|
||||||
|
|
|
@ -85,10 +85,10 @@ let previous_successful_build_different_output id (module Db : CONN) =
|
||||||
let next_successful_build_different_output id (module Db : CONN) =
|
let next_successful_build_different_output id (module Db : CONN) =
|
||||||
Db.find_opt Builder_db.Build.get_next_successful_different_output id
|
Db.find_opt Builder_db.Build.get_next_successful_different_output id
|
||||||
|
|
||||||
let failed_builds platform (module Db : CONN) =
|
let failed_builds ~start ~count 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 (start, count)
|
||||||
| 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 (start, count, p)
|
||||||
|
|
||||||
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 ->
|
||||||
|
|
|
@ -48,7 +48,7 @@ val previous_successful_build_different_output : [`build] Builder_db.id -> Caqti
|
||||||
val next_successful_build_different_output : [`build] Builder_db.id -> Caqti_lwt.connection ->
|
val next_successful_build_different_output : [`build] Builder_db.id -> Caqti_lwt.connection ->
|
||||||
(Builder_db.Build.t option, [> Caqti_error.call_or_retrieve ]) result Lwt.t
|
(Builder_db.Build.t option, [> Caqti_error.call_or_retrieve ]) result Lwt.t
|
||||||
|
|
||||||
val failed_builds : string option -> Caqti_lwt.connection ->
|
val failed_builds : start:int -> count:int -> string option -> Caqti_lwt.connection ->
|
||||||
((string * 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 ->
|
||||||
|
|
18
lib/views.ml
18
lib/views.ml
|
@ -216,7 +216,13 @@ let builder section_job_map =
|
||||||
jobs)
|
jobs)
|
||||||
])
|
])
|
||||||
section_job_map
|
section_job_map
|
||||||
[])
|
[] @
|
||||||
|
[ p [
|
||||||
|
txt "View the latest failed builds ";
|
||||||
|
a ~a:[a_href "/failed-builds/"]
|
||||||
|
[txt "here"];
|
||||||
|
txt "."
|
||||||
|
]])
|
||||||
|
|
||||||
let job name platform readme builds =
|
let job name platform readme builds =
|
||||||
layout ~nav:(`Job (name, platform)) ~title:(Fmt.str "Job %s %a" name pp_platform platform)
|
layout ~nav:(`Job (name, platform)) ~title:(Fmt.str "Job %s %a" name pp_platform platform)
|
||||||
|
@ -500,7 +506,7 @@ let compare_builds job_left job_right
|
||||||
code (key_value_changes changed_pkgs);
|
code (key_value_changes changed_pkgs);
|
||||||
])
|
])
|
||||||
|
|
||||||
let failed_builds builds =
|
let failed_builds ~start ~count builds =
|
||||||
let build (job_name, build) =
|
let build (job_name, build) =
|
||||||
li [
|
li [
|
||||||
txtf "%s %a " job_name pp_platform (Some build.Builder_db.Build.platform);
|
txtf "%s %a " job_name pp_platform (Some build.Builder_db.Build.platform);
|
||||||
|
@ -511,5 +517,11 @@ let failed_builds builds =
|
||||||
in
|
in
|
||||||
layout ~title:"Failed builds"
|
layout ~title:"Failed builds"
|
||||||
([ h1 [txt "Failed builds"];
|
([ h1 [txt "Failed builds"];
|
||||||
ul (List.map build builds) ])
|
ul (List.map build builds);
|
||||||
|
p [ txtf "View the next %d failed builds " count;
|
||||||
|
a ~a:[Fmt.kstr a_href "/failed-builds/?count=%d&start=%d" count (start + count)]
|
||||||
|
[ txt "here"];
|
||||||
|
txt ".";
|
||||||
|
]
|
||||||
|
])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue