Fix to the code extracting binary size for treemap visualization

This commit is contained in:
Robur 2021-12-15 16:17:56 +00:00 committed by Reynir Björnsson
parent d247846e35
commit 07b5daff9f

View file

@ -189,26 +189,20 @@ let add_routes datadir =
and build = Dream.param "build" req in and build = Dream.param "build" req in
get_uuid build >>= fun uuid -> get_uuid build >>= fun uuid ->
( (
Dream.sql req (Model.build uuid) >>= fun (id, _build) -> Dream.sql req (Model.build uuid) >>= fun (id, build) ->
Dream.sql req (Model.build_artifacts id) >>= fun binaries -> (* filepath = bin/caldav.hvt
Model.not_found ( localpath = caldav-monitoring/<uuid>/output/bin/caldav.hvt in datadir *)
List.find_map (fun f -> Model.not_found build.Builder_db.Build.main_binary >>= fun main_binary_id ->
if not @@ Fpath.has_ext "debug" f.Builder_db.filepath then None Dream.sql req (Model.build_artifact_by_id main_binary_id) >>= fun main_binary ->
else Some (f, binaries) let debug_binary_path = Fpath.(base main_binary.Builder_db.filepath + "debug") in
) binaries (* lookup debug_binary_path artifact *)
)) Dream.sql req (Model.build_artifact uuid debug_binary_path) >>= fun debug_binary ->
Lwt_result.return (debug_binary, main_binary))
|> if_error "Error getting job build" |> if_error "Error getting job build"
~log:(fun e -> Log.warn (fun m -> m "Error getting job build: %a" pp_error e)) ~log:(fun e -> Log.warn (fun m -> m "Error getting job build: %a" pp_error e))
>>= fun (debug_binary, binaries) -> >>= fun (debug_binary, main_binary) ->
Log.info (fun m -> m ">>>>>>>>>> debug-binary bound"); Log.info (fun m -> m ">>>>>>>>>> binary + debug-binary bound");
let binary_name = Fpath.rem_ext debug_binary.Builder_db.filepath in let binary_size = main_binary.Builder_db.size in
List.find_opt (fun f -> Fpath.equal f.Builder_db.filepath binary_name) binaries
|> Model.not_found
|> if_error "Error getting job build"
~log:(fun e -> Log.warn (fun m -> m "Error getting job build: %a" pp_error e))
>>= fun binary ->
Log.info (fun m -> m ">>>>>>>>>> binary bound");
let binary_size = binary.Builder_db.size in
let datadir = Dream.global datadir_global req in let datadir = Dream.global datadir_global req in
let path = Fpath.(datadir // debug_binary.Builder_db.localpath) in let path = Fpath.(datadir // debug_binary.Builder_db.localpath) in
let open Modulectomy in let open Modulectomy in