From 1c198385371b07a3b92deab9babc6a6737c0c5d8 Mon Sep 17 00:00:00 2001 From: Idir Lankri Date: Wed, 16 Oct 2024 12:23:13 +0200 Subject: [PATCH 1/4] Plugin_api: Make it possible to change the timeout for a given request --- src/plugin_api.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugin_api.ml b/src/plugin_api.ml index da9e0d5..53aa5f5 100644 --- a/src/plugin_api.ml +++ b/src/plugin_api.ml @@ -63,7 +63,8 @@ let () = try Scanf.sscanf s "dico_profession_%[a-z].csv" (aux `profession s) with _ -> () end (Sys.readdir assets) ; - let aux fn _assets conf base = + let aux ?timeout fn _assets conf base = + Option.iter Wserver.set_timeout timeout; set_request_timeout (); fn { conf with Geneweb.Config.api_mode = true } base ; true in From 67833c6effe2a8b86cf83a2938e1a6d13d1efba2 Mon Sep 17 00:00:00 2001 From: Idir Lankri Date: Thu, 17 Oct 2024 11:49:52 +0200 Subject: [PATCH 2/4] Plugin_api: Disable timeout for the endpoint `API_IMAGE_ALL` --- src/plugin_api.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin_api.ml b/src/plugin_api.ml index 53aa5f5..ef7f662 100644 --- a/src/plugin_api.ml +++ b/src/plugin_api.ml @@ -96,7 +96,7 @@ let () = ; ( "API_INFO_IND" , aux @@ w_base @@ Plugin_api_lib.Api.print_info_ind) ; ( "API_IMAGE_ALL" - , aux @@ w_base @@ Plugin_api_lib.Api.print_img_all) + , aux ~timeout:0 @@ w_base @@ Plugin_api_lib.Api.print_img_all) ; ( "API_IMAGE_PERSON" , aux @@ w_base @@ Plugin_api_lib.Api.print_img_person) ; ( "API_IMAGE_UPDATE" From f6d922cfa8865aeb99813a6d7a486ce14d94befd Mon Sep 17 00:00:00 2001 From: Idir Lankri Date: Mon, 21 Oct 2024 10:58:14 +0200 Subject: [PATCH 3/4] Cleanup: Delete some trailing white spaces --- src/assets/api.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/api.proto b/src/assets/api.proto index b973195..28c5e33 100644 --- a/src/assets/api.proto +++ b/src/assets/api.proto @@ -804,7 +804,7 @@ message HistoryPerson { optional int32 year1 = 6; optional int32 year2 = 7; required bool exists_in_base = 8; - required bool has_history = 9; + required bool has_history = 9; } message HistoryNote { From bc463f3498ab8a01c8a523776665e0473664a8ab Mon Sep 17 00:00:00 2001 From: Idir Lankri Date: Mon, 21 Oct 2024 10:58:43 +0200 Subject: [PATCH 4/4] Api: Lighten the request getting all portraits of a given database We only need to return the surname, the first name and the occurrence number of the person. --- src/api.ml | 20 ++++++-------------- src/assets/api.proto | 11 +---------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/api.ml b/src/api.ml index a781007..567127b 100644 --- a/src/api.ml +++ b/src/api.ml @@ -417,20 +417,12 @@ let print_img_all conf base = else Api_util.print_result conf (fl list) in - let compute_sosa = Api_util.compute_sosa conf base false in - if Api_util.p_getenvbin conf.env "full_infos" = Some "1" then - aux - (fun p img -> - let p = Api_util.pers_to_piqi_person_full conf base p compute_sosa in - Api_piqi.Full_image.({person = p; img = img;})) - (fun list -> Api_piqi_ext.gen_list_full_images @@ Api_piqi.List_full_images.({images = list}) ) - else - aux - (fun p img -> - let p = Api_util.pers_to_piqi_person_light conf base p compute_sosa in - Api_piqi.Image.({person = p; img})) - (fun list -> - Api_piqi_ext.gen_list_images @@ Api_piqi.List_images.({list_images = list})) + aux + (fun p img -> + let p = Api_util.person_to_reference_person base p in + Api_piqi.Image.({person = p; img})) + (fun list -> + Api_piqi_ext.gen_list_images @@ Api_piqi.List_images.({list_images = list})) (**/**) (* API_IMAGE_APP *) diff --git a/src/assets/api.proto b/src/assets/api.proto index 28c5e33..c40db94 100644 --- a/src/assets/api.proto +++ b/src/assets/api.proto @@ -241,12 +241,7 @@ message SearchParams { } message Image { - required Person person = 1; - required string img = 2; -} - -message FullImage { - required FullPerson person = 1; + required ReferencePerson person = 1; required string img = 2; } @@ -254,10 +249,6 @@ message ListImages { repeated Image list_images = 1; } -message ListFullImages { - repeated FullImage images = 1; -} - message PersImg { required ReferencePerson person = 1; required string img = 2;