Random fixin's in preparation for accepting new members
[bpt/portal.git] / poll.sml
index 32e588d..e549218 100644 (file)
--- a/poll.sml
+++ b/poll.sml
@@ -202,4 +202,17 @@ fun listVoters cho =
                                     AND cho = ^(C.intToSql cho)
                                  ORDER BY name`)
 
-end
\ No newline at end of file
+fun countVoters pol =
+    case C.oneRow (getDb ()) ($`SELECT COUNT(DISTINCT usr)
+                               FROM Vote JOIN PollChoice ON id = cho AND pol = ^(C.intToSql pol)`) of
+       [count] => C.intFromSql count
+      | row => Init.rowError ("countVoters", row)
+
+fun listPollVoters pol =
+    C.map (getDb ()) mkUserRow ($`SELECT DISTINCT WebUser.id, name, rname, bal, joined, app
+                                 FROM WebUser, Vote JOIN PollChoice ON cho = PollChoice.id
+                                 WHERE pol = ^(C.intToSql pol)
+                                    AND usr = WebUser.id
+                                 ORDER BY name`)
+
+end