+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, paypal, checkout
+ FROM WebUser, Vote JOIN PollChoice ON cho = PollChoice.id
+ WHERE pol = ^(C.intToSql pol)
+ AND usr = WebUser.id
+ ORDER BY name`)
+
+val votingMembershipRequirement = 45
+
+fun membershipLength id =
+ case C.oneRow (getDb ()) ($`SELECT EXTRACT(DAY FROM (CURRENT_TIMESTAMP - joined))
+ FROM WebUser
+ WHERE id = ^(C.intToSql id)`) of
+ [days] => C.intFromSql days
+ | row => Init.rowError ("membershipLength", row)
+
+end