-
Notifications
You must be signed in to change notification settings - Fork 2
poc api2 #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gnt
Are you sure you want to change the base?
Conversation
ilankri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fields are optional to ease the switch to Proto3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| let person_select_of_piqi_request piqi_request = | |
| let requested_index = piqi_request.Api_v2_piqi.Request.index in | |
| let requested_npocc = piqi_request.Api_v2_piqi.Request.npocc in | |
| match requested_index, requested_npocc with | |
| | Some index, _ -> Some (Common.Index index) | |
| | _, Some Api_v2_piqi.Npocc.{n = Some n; p = Some p; occ = Some occ} -> Some (Common.Npocc {n; p; occ}) | |
| | _, _ -> None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?!
src/common.ml
Outdated
|
|
||
| type event_request = { | ||
| page_number : int; | ||
| elements_per_page : int; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| (*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.