X-Git-Url: https://git.hcoop.net/hcoop/zz_old/portal.git/blobdiff_plain/369e1577bf72be99dcbb142fe605e5b4e6548102..66db411c02f88151a7a93e6e9f70345cd536fe4c:/poll.sml diff --git a/poll.sml b/poll.sml index 987c5e2..1d08f70 100644 --- a/poll.sml +++ b/poll.sml @@ -196,10 +196,23 @@ fun noDupes l = | h::t => List.all (fn x => x <> h) t andalso noDupes t fun listVoters cho = - C.map (getDb ()) mkUserRow ($`SELECT id, name, rname, bal, joined + C.map (getDb ()) mkUserRow ($`SELECT id, name, rname, bal, joined, app, shares FROM WebUser, Vote WHERE usr = id 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, shares + FROM WebUser, Vote JOIN PollChoice ON cho = PollChoice.id + WHERE pol = ^(C.intToSql pol) + AND usr = WebUser.id + ORDER BY name`) + +end