Commits

Kakadu  committed 131f1ad

Working

  • Participants
  • Parent commits b812d29
  • Branches neo

Comments (0)

Files changed (3)

 
 
 let by_date tlsort ~yy ~dd ~mm : Types.Event.t list Lwt.t =
-  let date_text = sprintf "%d-%02d-%2d" yy mm dd in
+  let date_text = sprintf "%d-%02d-%02d" yy mm dd in
   let cmd1 = sprintf "match (d :DATE_ITEM{when:\"%s\"}),
                       (d)<-[:WHEN]-(l),(d)<-[:WHEN]-(f),
                       path=(f)-[:FOLLOWED_BY*0..]->(l)
                       return d,nodes(path);" date_text in
   let ans = post_cypher cmd1 in
-  (*print_endline ans;*)
+  print_endline ans;
   match to_json ans with
   | `Assoc [_;("data",`List [`List [`Assoc dj; `List nodes ]])] ->
      Lwt.return @@ List.map ~f:(function `Assoc x -> event_of_json dj x | _ -> assert false) nodes
   | _ -> failwith "Wrong JSON format"
+
+let day_by_eventid id =
+  print_endline "day_by_eventid";
+  let cmd = sprintf "START event=node(%Ld) MATCH (d)<-[:WHEN]-(event) MATCH (d)<-[:WHEN]-(l), (d)<-[:WHEN]-(f)
+                     MATCH path=(f)-[:FOLLOWED_BY*0..]->(l)
+                     OPTIONAL MATCH (prevd)<-[:WHEN]-(prev)-[:FOLLOWED_BY]->(f)
+                     OPTIONAL MATCH (l)-[:FOLLOWED_BY]->(next)-[:WHEN]->(nextd)
+                     RETURN d, nodes(path), prev, prevd, next, nextd;" id in
+  let ans = post_cypher cmd in
+  print_endline ans;
+  match to_json ans with
+  | `Assoc [_;("data",`List [`List [`Assoc dj; `List nodes; prev; prevd; next; nextd ]])] ->
+    (dj,nodes,prev,next)
+  | _ -> failwith "Wrong JSON format"
+
+
 
 let post_cypher ?(server= (!options).server) ?(port = !options.port) ?(params=[]) cypher =
   let url = sprintf "http://%s:%d/db/data/cypher" server port in
-  print_endline url;
   let pipeline = new Http_client.pipeline in
   let opt = pipeline # get_options in
   pipeline # set_options
                       ("params", `Assoc params) ] in (*
                (List.Labels.map params ~f:(fun (name,j) -> (name,Yojson.to_string j))) in
                                           *)
-  printf "Args: %s\n%!" (Yojson.to_string args);
+  (*printf "Args: %s\n%!" (Yojson.to_string args);*)
+  print_endline cypher;
   let req = new Http_client.post_raw url (Yojson.to_string args) in
   (*
   let req = new Http_client.post url
   let yy = CalendarLib.Date.(year date) in
   lwt events = Neo_db.by_date tlsort ~yy ~dd ~mm in
 
+  let (_,_,_,_) = Neo_db.day_by_eventid eventId in
+
   (* next two ids are used to make navigation links (back/forward) *)
   let nextEventId,prevEventId = None,None in
   (*