Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (def vote-results-query
- '[$votes
- [:find ?issue, ?proposal-name, (count ?vote) :as vote-count
- :in $ ?issue
- :where
- [?ballot :ballot/issue ?issue]
- ;; Bind the proposal
- [?proposal :proposal/name ?proposal-name]
- ;; Count only votes for this Ballot
- [?vote :voter/ballot ?ballot]
- ;; Bind the votes for this proposal
- [?vote :voter/vote-on-proposal ?proposal]]
- $most-voted
- [:find (max ?vote-count) :as winning-vote-count .
- ;-- this statement:
- :within $votes
- ;-- gets rewritten as:
- :in [[?issue ?proposal-name ?vote-count]]]
- ;--
- $winners
- [:find ?proposal-name ?proposal-votes
- ;-- this statement:
- :within $votes $most-voted
- ;-- gets rewritten as:
- :in [[?issue ?proposal-name ?vote-count]] ?winning-vote-count
- ;--
- :where [(= ?winning-vote-count ?proposal-votes)]]])
Add Comment
Please, Sign In to add comment