Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
belenios
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
belenios
belenios
Commits
347654be
Commit
347654be
authored
Nov 10, 2015
by
Stephane Glondu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More precise get_election_state
parent
6dc2ce79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
src/web/web_persist.ml
src/web/web_persist.ml
+13
-10
No files found.
src/web/web_persist.ml
View file @
347654be
...
...
@@ -26,6 +26,15 @@ open Common
open
Web_serializable_j
open
Web_common
let
(
/
)
=
Filename
.
concat
let
get_election_result
uuid
=
try_lwt
Lwt_io
.
chars_of_file
(
!
spool_dir
/
uuid
/
"result.json"
)
|>
Lwt_stream
.
to_string
>>=
fun
x
->
return
@@
Some
(
result_of_string
(
Yojson
.
Safe
.
from_lexbuf
~
stream
:
true
)
x
)
with
_
->
return_none
type
election_state
=
[
`Open
|
`Closed
...
...
@@ -37,7 +46,10 @@ let election_states = Ocsipersist.open_table "election_states"
let
get_election_state
x
=
try_lwt
Ocsipersist
.
find
election_states
x
with
Not_found
->
return
`Open
with
Not_found
->
match_lwt
get_election_result
x
with
|
Some
r
->
return
(
`Tallied
r
.
result
)
|
None
->
return
`Open
let
set_election_state
x
s
=
Ocsipersist
.
add
election_states
x
s
...
...
@@ -71,8 +83,6 @@ let get_auth_config x =
let
set_auth_config
x
c
=
Ocsipersist
.
add
auth_configs
x
c
let
(
/
)
=
Filename
.
concat
let
get_raw_election
uuid
=
try_lwt
let
lines
=
Lwt_io
.
lines_of_file
(
!
spool_dir
/
uuid
/
"election.json"
)
in
...
...
@@ -89,13 +99,6 @@ let get_election_metadata uuid =
return
@@
Some
(
metadata_of_string
x
)
with
_
->
return_none
let
get_election_result
uuid
=
try_lwt
Lwt_io
.
chars_of_file
(
!
spool_dir
/
uuid
/
"result.json"
)
|>
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
->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment