Conversation
ilankri
left a comment
There was a problem hiding this comment.
It is on the right track! The naming of the Protobuf messages and OCaml functions might need to be adjusted later.
| message Npocc { | ||
| optional string n = 1; | ||
| optional string p = 2; | ||
| optional int32 occ = 3; | ||
| } |
There was a problem hiding this comment.
The fields are optional to ease the switch to Proto3?
There was a problem hiding this comment.
In part, but even if there is never a switch to Proto3, it can cause many issues.
https://protobuf.dev/programming-guides/proto2/#required-deprecated
| message Request { | ||
| optional int32 index = 1; | ||
| optional Npocc npocc = 2; | ||
| optional PersonRequest person_request = 3; | ||
| } |
There was a problem hiding this comment.
Maybe we should have two distinct messages RequestByIndex and RequestByNpocc? To avoid this:
geneweb-plugin-api/src/request.ml
Lines 15 to 21 in 3ca3ecd
There was a problem hiding this comment.
we can, but that means two different endpoints, which is not an issue in itself. It would then be on the client to ask the right one.
src/common.ml
Outdated
| if person.fields.image then | ||
| Api_util.get_portrait person.conf person.base person.person | ||
| else None |
There was a problem hiding this comment.
| if person.fields.image then | |
| Api_util.get_portrait person.conf person.base person.person | |
| else None | |
| Ext_option.return_if person.fields.image (fun () -> | |
| Api_util.get_portrait person.conf person.base person.person | |
| ) |
src/common.ml
Outdated
| if person.confidentiality.restricted then None | ||
| else | ||
| Option.bind fields (fun fields -> | ||
| Option.bind (Gwdb.get_parents person.person) (fun parents -> | ||
| let iparent = proj (Gwdb.foi person.base parents) in | ||
| let parent = Gwdb.poi person.base iparent in | ||
| Option.some (of_person person.conf person.base fields parent)) | ||
| ) |
There was a problem hiding this comment.
| if person.confidentiality.restricted then None | |
| else | |
| Option.bind fields (fun fields -> | |
| Option.bind (Gwdb.get_parents person.person) (fun parents -> | |
| let iparent = proj (Gwdb.foi person.base parents) in | |
| let parent = Gwdb.poi person.base iparent in | |
| Option.some (of_person person.conf person.base fields parent)) | |
| ) | |
| Ext_option.return_if (not person.confidentiality.restricted (fun () -> | |
| Option.bind fields (fun fields -> | |
| Option.bind (Gwdb.get_parents person.person) (fun parents -> | |
| let iparent = proj (Gwdb.foi person.base parents) in | |
| let parent = Gwdb.poi person.base iparent in | |
| Option.some (of_person person.conf person.base fields parent)) | |
| ) | |
| ) |
src/common.ml
Outdated
| let event_type base e = match e with | ||
| | Geneweb.Event.Pevent (Def.Epers_Name istr) -> Geneweb.Event.Pevent (Def.Epers_Name (Utf8.normalize (Gwdb.sou base istr))) | ||
| | Geneweb.Event.Fevent (Def.Efam_Name istr) -> Geneweb.Event.Fevent (Def.Efam_Name (Utf8.normalize (Gwdb.sou base istr))) | ||
| | _ as e -> (Obj.magic e) |
src/common.ml
Outdated
|
|
||
| type event_request = { | ||
| page_number : int; | ||
| elements_per_page : int; |
There was a problem hiding this comment.
| elements_per_page : int; | |
| elements_per_page : [ `Int of int | `All ] ; |
src/common.ml
Outdated
| if not (has_visible_names person) then None | ||
| else | ||
| of_field person.fields.npocc (fun person' -> | ||
| let lowered_string proj person = Name.lower (as_string proj person) in | ||
| { | ||
| n = lowered_string Gwdb.get_first_name person; | ||
| p = lowered_string Gwdb.get_surname person; | ||
| occ = Int32.of_int (Gwdb.get_occ person'); | ||
| } | ||
| ) person |
There was a problem hiding this comment.
| if not (has_visible_names person) then None | |
| else | |
| of_field person.fields.npocc (fun person' -> | |
| let lowered_string proj person = Name.lower (as_string proj person) in | |
| { | |
| n = lowered_string Gwdb.get_first_name person; | |
| p = lowered_string Gwdb.get_surname person; | |
| occ = Int32.of_int (Gwdb.get_occ person'); | |
| } | |
| ) person | |
| Ext_option.return_if (has_visible_names person) (fun () -> | |
| of_field person.fields.npocc (fun person' -> | |
| let lowered_string proj person = Name.lower (as_string proj person) in | |
| { | |
| n = lowered_string Gwdb.get_first_name person; | |
| p = lowered_string Gwdb.get_surname person; | |
| occ = Int32.of_int (Gwdb.get_occ person'); | |
| } | |
| ) person | |
| ) |
src/common.ml
Outdated
| (*let as_some_string ?(none_if_empty = false) proj person = | ||
| let s = as_string proj person in | ||
| Ext_option.return_if (not none_if_empty || s <> "") (fun () -> s)*) |
There was a problem hiding this comment.
| (*let as_some_string ?(none_if_empty = false) proj person = | |
| let s = as_string proj person in | |
| Ext_option.return_if (not none_if_empty || s <> "") (fun () -> s)*) |
No description provided.