summaryrefslogtreecommitdiff
path: root/desk/sur/polls.hoon
blob: 93085c293dbec2eaa1d602036f6733cad9e36319 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/-  gate=trill-gate
|%
+$  pid     [ship=@p id=@da]
+$  id      @da
+$  expiry  @da
+$  text    @t
+$  poll
$:  author=ship
    =time
    =expiry
    =text
    options=(list @t)
    =votes
    read=lock:gate
    write=lock:gate
==
+$  votes
$%  excl
    incl
==
+$  excl  [%exc p=(map ship @ud)]
+$  incl  [%inc p=(map @ud (map @p (set @ud)))]
::  some helpers

++  new-poll
|=  [=pid =text =expiry options=(list @t) inc=?]
=/  votes  ?.  inc  *excl  *incl  
^-  poll
:*  author=-.pid
    time=+.pid
    expiry
    text
    options
    votes
    read=*lock:gate
    write=*lock:gate
==
::  comms
+$  ui-action
$%  [%propose text=@t =expiry options=(list @t) exc=?]
    [%cancel =id]
    [%change-expiry =id =expiry]
    [%vote =pid option=@ comment=@t]
    [%cancel-vote =pid]
==
+$  update
$%  [%new-poll =poll]
    [%ded-poll p=pid]
    [%old-poll p=poll q=upd]
==
+$  upd
$?  [%new-vote p=@ud]
    [%expiry-changed q=expiry]
    [%vote-changed p=@p old=@ new=@]
    [%vote-canceled p=@p q=@]
==
--