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
05e8536b
Commit
05e8536b
authored
Nov 05, 2015
by
Stephane Glondu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop using election_ptable
We keep it around for server upgrades...
parent
3df1e5ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
11 deletions
+18
-11
src/web/web_persist.ml
src/web/web_persist.ml
+9
-0
src/web/web_persist.mli
src/web/web_persist.mli
+2
-0
src/web/web_site.ml
src/web/web_site.ml
+7
-11
No files found.
src/web/web_persist.ml
View file @
05e8536b
...
...
@@ -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
src/web/web_persist.mli
View file @
05e8536b
...
...
@@ -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
src/web/web_site.ml
View file @
05e8536b
...
...
@@ -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
...
...
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