Skip to content

Commit 9c5de2e

Browse files
canoniciilankri
authored andcommitted
Merge pull request #69 from geneanet/gnt-search-aliases
add matching aliases in person search returned values
2 parents 62fbada + c7b5019 commit 9c5de2e

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

src/api_saisie_write.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ let print_person_search_list conf base =
5959
else c1
6060
in
6161
let persons = List.sort cmp_per persons in
62-
let list = List.map (fun p ->
63-
Api_update_util.pers_to_piqi_person_search conf base p
62+
let list = List.map (fun person ->
63+
Api_update_util.pers_to_piqi_person_search ~conf ~base ~person ~first_name ~surname
6464
) persons in
6565
let result = Api_saisie_write_piqi.Person_search_list.({ persons = list; }) in
6666
let data = Api_saisie_write_piqi_ext.gen_person_search_list result in

src/api_update_util.ml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -598,29 +598,39 @@ let pers_to_piqi_simple_person (conf : Geneweb.Config.config) (base : Gwdb.base)
598598
}
599599

600600

601-
let pers_to_piqi_person_search conf base p =
602-
let index = Int32.of_string @@ Gwdb.string_of_iper (Gwdb.get_iper p) in
601+
let pers_to_piqi_person_search ~conf ~base ~person ~first_name ~surname =
602+
let index = Int32.of_string @@ Gwdb.string_of_iper (Gwdb.get_iper person) in
603603
let sex =
604-
match Gwdb.get_sex p with
604+
match Gwdb.get_sex person with
605605
| Def.Male -> `male
606606
| Def.Female -> `female
607607
| Def.Neuter -> `unknown
608608
in
609609
let sosa =
610-
let sosa_nb = Geneweb.Sosa_cache.get_sosa_person ~conf ~base ~person:p in
610+
let sosa_nb = Geneweb.Sosa_cache.get_sosa_person ~conf ~base ~person in
611611
if Sosa.eq sosa_nb Sosa.zero then `no_sosa
612612
else if Sosa.eq sosa_nb Sosa.one then `sosa_ref
613613
else `sosa
614614
in
615+
let matching_first_name_aliases =
616+
Geneweb.AdvSearchOk.prefix_matching_first_name_aliases
617+
~first_name
618+
~aliases:(List.map (Gwdb.sou base) (Gwdb.get_first_names_aliases person))
619+
in
620+
let matching_surname_aliases =
621+
Geneweb.AdvSearchOk.prefix_matching_surname_aliases
622+
~surname
623+
~aliases:(List.map (Gwdb.sou base) (Gwdb.get_surnames_aliases person))
624+
in
615625
let (first_name, surname) =
616-
Api_saisie_read.person_firstname_surname_txt base p
626+
Api_saisie_read.person_firstname_surname_txt base person
617627
in
618-
let dates = Api_saisie_read.short_dates_text conf base p in
619-
let image = Api_util.get_portrait conf base p in
628+
let dates = Api_saisie_read.short_dates_text conf base person in
629+
let image = Api_util.get_portrait conf base person in
620630
let family =
621-
let hw = husband_wife conf base p in
631+
let hw = husband_wife conf base person in
622632
if hw <> "" then hw
623-
else child_of_parent conf base p
633+
else child_of_parent conf base person
624634
in
625635
{
626636
Api_saisie_write_piqi.Person_search.index = index;
@@ -631,6 +641,8 @@ let pers_to_piqi_person_search conf base p =
631641
image;
632642
sosa = sosa;
633643
family = family;
644+
matching_first_name_aliases;
645+
matching_surname_aliases;
634646
}
635647

636648

src/api_update_util.mli

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ val date_of_piqi_date :
7070
Geneweb.Config.config -> Api_saisie_write_piqi.date -> Date.date option
7171

7272
val pers_to_piqi_person_search :
73-
Geneweb.Config.config ->
74-
Gwdb.base ->
75-
Gwdb.person ->
73+
conf:Geneweb.Config.config ->
74+
base:Gwdb.base ->
75+
person:Gwdb.person ->
76+
first_name:string ->
77+
surname:string ->
7678
Api_saisie_write_piqi.person_search
7779
(** [Description] : Retourne une personne qui sert lors de la recherche pour
7880
relier un individu dans la saisie. *)

src/assets/api_saisie_write.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ message PersonSearch {
8585
optional string image = 6;
8686
required Sosa sosa = 7;
8787
required string family = 8;
88+
repeated string matching_first_name_aliases = 9;
89+
repeated string matching_surname_aliases = 10;
8890
}
8991

9092
message SimplePerson {

0 commit comments

Comments
 (0)