Commit 05e8536b authored by Stephane Glondu's avatar Stephane Glondu

Stop using election_ptable

We keep it around for server upgrades...
parent 3df1e5ec
......@@ -95,3 +95,12 @@ let get_election_result uuid =
Lwt_stream.to_string >>= fun x ->
return @@ Some (result_of_string (Yojson.Safe.from_lexbuf ~stream:true) x)
with _ -> return_none
let get_elections_by_owner user =
Lwt_unix.files_of_directory !spool_dir |>
Lwt_stream.filter_s (fun x ->
if x = "." || x = ".." then return false else
match_lwt get_election_metadata x with
| Some m -> return (m.e_owner = Some user)
| None -> return false
) |> Lwt_stream.to_list
......@@ -43,3 +43,5 @@ val set_auth_config : string -> (string * (string * string list)) list -> unit L
val get_raw_election : string -> string option Lwt.t
val get_election_metadata : string -> metadata option Lwt.t
val get_election_result : string -> Yojson.Safe.json result option Lwt.t
val get_elections_by_owner : user -> string list Lwt.t
......@@ -125,10 +125,10 @@ let import_election f =
let module P = (val params : ELECTION_DATA) in
let uuid = Uuidm.to_string P.election.e_params.e_uuid in
lwt exists =
try_lwt
lwt _ = Ocsipersist.find election_ptable uuid in
return true
with Not_found -> return false
lwt x = Web_persist.get_raw_election uuid in
match x with
| Some _ -> return true
| None -> return false
in
if exists then (
Lwt_mutex.unlock registration_mutex;
......@@ -260,9 +260,8 @@ let () = Html5.register ~service:admin
| None -> return None
| Some u ->
lwt elections, tallied =
Ocsipersist.fold_step (fun uuid_s (_, web_params) accu ->
let module W = (val web_params : WEB_PARAMS) in
if W.metadata.e_owner = Some u then (
Web_persist.get_elections_by_owner u >>=
Lwt_list.fold_left_s (fun accu uuid_s ->
lwt w = find_election uuid_s in
lwt state = Web_persist.get_election_state uuid_s in
lwt date = Web_persist.get_election_date uuid_s in
......@@ -270,10 +269,7 @@ let () = Html5.register ~service:admin
match state with
| `Tallied _ -> return (elections, (date, w) :: tallied)
| _ -> return ((date, w) :: elections, tallied)
) else (
return accu
)
) election_ptable ([], [])
) ([], [])
and setup_elections =
Ocsipersist.fold_step (fun k v accu ->
if v.se_owner = u
......
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