Commit 83eb868b authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Dedicated file for dates

parent 199a023e
...@@ -58,12 +58,27 @@ let election_dates = Ocsipersist.open_table "election_dates" ...@@ -58,12 +58,27 @@ let election_dates = Ocsipersist.open_table "election_dates"
let past = datetime_of_string "\"2015-10-01 00:00:00.000000\"" let past = datetime_of_string "\"2015-10-01 00:00:00.000000\""
let get_election_date x = let set_election_date uuid d =
try_lwt Ocsipersist.find election_dates x Ocsipersist.add election_dates uuid d >>
with Not_found -> return past let dates = { e_finalization = d } in
Lwt_io.(with_file Output (!spool_dir / uuid / "dates.json") (fun oc ->
let set_election_date x d = write_line oc (string_of_election_dates dates)
Ocsipersist.add election_dates x d ))
let get_election_date uuid =
try_lwt
(* Temporary *)
lwt d = Ocsipersist.find election_dates uuid in
set_election_date uuid d >>
return d
with Not_found ->
try_lwt
Lwt_io.chars_of_file (!spool_dir / uuid / "dates.json") |>
Lwt_stream.to_string >>= fun x ->
let dates = election_dates_of_string x in
return dates.e_finalization
with _ ->
return past
let election_pds = Ocsipersist.open_table "election_pds" let election_pds = Ocsipersist.open_table "election_pds"
......
...@@ -60,3 +60,7 @@ type datadir_index = datadir_item list ...@@ -60,3 +60,7 @@ type datadir_index = datadir_item list
type election_uuid = { type election_uuid = {
uuid : uuid; uuid : uuid;
} <ocaml field_prefix="election_"> } <ocaml field_prefix="election_">
type election_dates = {
finalization : datetime;
} <ocaml field_prefix="e_">
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment