Make json structure uniform #6

Merged
reynir merged 3 commits from pixiedust-patch-1 into main 2025-01-06 15:01:10 +00:00
2 changed files with 6 additions and 7 deletions

View file

@ -411,7 +411,7 @@ let routes ~datadir ~cachedir ~configdir ~expired_jobs =
if is_accept_json req then if is_accept_json req then
let json_response = let json_response =
`Assoc [ `Assoc [
"job_name", `String job_name; "job", `String job_name;
"uuid", `String (Uuidm.to_string build.uuid); "uuid", `String (Uuidm.to_string build.uuid);
"platform", `String build.platform; "platform", `String build.platform;
"start_time", `String (Ptime.to_rfc3339 build.start); "start_time", `String (Ptime.to_rfc3339 build.start);
@ -621,7 +621,7 @@ let routes ~datadir ~cachedir ~configdir ~expired_jobs =
let json_response = let json_response =
`Assoc [ `Assoc [
"left", `Assoc [ "left", `Assoc [
"job_name", `String job_left; "job", `String job_left;
PixieDust marked this conversation as resolved
Review

Can we apply the same change in job_build?

Can we apply the same change in `job_build`?
"uuid", `String (Uuidm.to_string build_left.uuid); "uuid", `String (Uuidm.to_string build_left.uuid);
"platform", `String build_left.platform; "platform", `String build_left.platform;
"start_time", `String (Ptime.to_rfc3339 build_left.start); "start_time", `String (Ptime.to_rfc3339 build_left.start);
@ -630,8 +630,8 @@ let routes ~datadir ~cachedir ~configdir ~expired_jobs =
"main_binary_size", file_size_json build_left_file_size; "main_binary_size", file_size_json build_left_file_size;
]; ];
"right", `Assoc [ "right", `Assoc [
"job_name", `String job_right; "job", `String job_right;
"build", `String (Uuidm.to_string build_right.uuid); "uuid", `String (Uuidm.to_string build_right.uuid);
"platform", `String build_right.platform; "platform", `String build_right.platform;
"start_time", `String (Ptime.to_rfc3339 build_right.start); "start_time", `String (Ptime.to_rfc3339 build_right.start);
"finish_time", `String (Ptime.to_rfc3339 build_right.finish); "finish_time", `String (Ptime.to_rfc3339 build_right.finish);

View file

@ -1,4 +1,3 @@
module String_map = struct module String_map = struct
include Map.Make(String) include Map.Make(String)
@ -16,8 +15,8 @@ let diff_map_to_json (left, right, different_versions) =
`List (List.map (fun (name, version1, version2) -> `List (List.map (fun (name, version1, version2) ->
`Assoc [ `Assoc [
("name", `String name); ("name", `String name);
("version_in_left", `String version1); ("version_left", `String version1);
("version_in_right", `String version2) ("version_right", `String version2)
] ]
) lst) ) lst)
in in