aboutsummaryrefslogtreecommitdiffstats
path: root/lib/server.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/server.ml')
-rw-r--r--lib/server.ml15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/server.ml b/lib/server.ml
index 22bee73..3a6d1fa 100644
--- a/lib/server.ml
+++ b/lib/server.ml
@@ -22,7 +22,20 @@ let client_read sock maxlen =
then Lwt.return acc
else _read sock acc in
_read sock String.empty
- >>= fun _ -> match Relation.write_and_retrieve() with | Ok results -> return results | Error err -> return err
+ >>= fun _ ->
+ match Relation.write_and_retrieve () with
+ | Ok (last_commit::_, locations) ->
+ begin
+ let (first_names, last_names) = (Planner.Scan.execute last_commit locations "user/first-name", Planner.Scan.execute last_commit locations "user/last-name") in
+ let tuples = Planner.Join.execute first_names last_names locations in
+ let (fname, lname) = List.split tuples in
+ let relation_result: Relation.Protocol.facts =
+ [{attribute_name = "user/first-name"; attribute_type = "string"; tuples = List.map Bytes.to_string fname};
+ {attribute_name = "user/last-name"; attribute_type = "string"; tuples = List.map Bytes.to_string lname}] in
+ return @@ Xml.to_string (Relation.Protocol.facts_to_xml_light relation_result)
+ end
+ | Ok _ -> return "Unstable"
+ | Error err -> return err
let rec socket_read sock =
(* (Int32.of_int (String.length results))) *)