Skip to content

Commit

Permalink
refactor(proposal-detail): add votetally to each doc
Browse files Browse the repository at this point in the history
  • Loading branch information
arsenijesavic committed Sep 20, 2023
1 parent 0e84c12 commit 6961e5d
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 39 deletions.
33 changes: 16 additions & 17 deletions src/components/proposals/voter-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@ import gql from 'graphql-tag'
import paginate from '~/utils/paginate'
const PROPOSAL_VOTES_QUERY = `
getDocument(docId: $docId) {
__typename
docId
... on Votable {
__typename
queryVote(first: $first, offset: $offset) @cascade {
voteon(filter: { docId: { eq: $docId } }) {
docId
type
}
voteAggregate {
voteonAggregate {
count
}
vote(first: $first, offset: $offset, order: { desc: createdDate }) {
username: vote_voter_n
vote: vote_vote_s
strength: vote_votePower_a
}
}
vote: vote_vote_s
username: vote_voter_n
strength: vote_votePower_a
}
`
export default {
Expand All @@ -42,14 +40,15 @@ export default {
page: 0,
size: 5,
voices: {},
voteCount: 0
voteCount: 0,
votes: []
}
},
apollo: {
votes: {
query: gql`query proposalVotes($docId: String!, $first: Int!, $offset: Int!) { ${PROPOSAL_VOTES_QUERY} }`,
update: data => data.getDocument.vote,
update: data => data.queryVote,
skip () { return !this.proposalId },
variables () {
return {
Expand All @@ -60,9 +59,9 @@ export default {
},
result ({ data }) {
this.voteCount = data?.getDocument?.voteAggregate?.count
this.voteCount = data.queryVote[0].voteonAggregate.count
},
fetchPolicy: 'no-cache',
// fetchPolicy: 'no-cache',
pollInterval: 1000
// subscribeToMore: {
// document: gql`subscription proposalVotes($docId: String!, $first: Int, $offset: Int) { ${PROPOSAL_VOTES_QUERY} }`,
Expand Down
158 changes: 136 additions & 22 deletions src/pages/proposals/ProposalDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ const PROPOSAL_QUERY = `
details_ballotSupply_a
details_ballotAlignment_i
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
cmntsect {
docId
Expand Down Expand Up @@ -91,6 +101,17 @@ const PROPOSAL_QUERY = `
details_ballotQuorum_i
details_ballotSupply_a
details_ballotAlignment_i
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
circle {
... on Circle {
id: docId
Expand Down Expand Up @@ -163,6 +184,16 @@ const PROPOSAL_QUERY = `
details_ballotAlignment_i
details_url_s
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
lockedby {
docId
}
Expand Down Expand Up @@ -217,6 +248,16 @@ const PROPOSAL_QUERY = `
details_ballotSupply_a
details_ballotAlignment_i
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
queststart {
details_title_s
system_description_s
Expand Down Expand Up @@ -271,6 +312,16 @@ const PROPOSAL_QUERY = `
details_url_s
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
parentcircle {
... on Circle {
id: docId
Expand Down Expand Up @@ -325,6 +376,16 @@ const PROPOSAL_QUERY = `
details_ballotQuorum_i
details_ballotSupply_a
details_ballotAlignment_i
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
parentcircle {
... on Circle {
Expand Down Expand Up @@ -403,6 +464,16 @@ const PROPOSAL_QUERY = `
details_owner_n
details_url_s
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
dao {
details_daoName_n
}
Expand Down Expand Up @@ -444,6 +515,16 @@ const PROPOSAL_QUERY = `
dao {
details_daoName_n
}
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
original {
__typename
... on Assignment {
Expand Down Expand Up @@ -537,6 +618,17 @@ const PROPOSAL_QUERY = `
details_ballotQuorum_i
details_ballotSupply_a
details_ballotAlignment_i
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
salaryband {
details_annualUsdSalary_a
details_name_s
Expand Down Expand Up @@ -622,6 +714,16 @@ const PROPOSAL_QUERY = `
details_ballotSupply_a
details_ballotAlignment_i
creator
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
start {
details_startTime_t
}
Expand Down Expand Up @@ -691,6 +793,16 @@ const PROPOSAL_QUERY = `
details_minTimeShareX100_i
details_owner_n
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
details_url_s
dao {
details_daoName_n
Expand All @@ -713,6 +825,16 @@ const PROPOSAL_QUERY = `
details_ballotAlignment_i
details_purpose_s
system_proposer_n
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
assignment {
details_assignee_n
dao {
Expand Down Expand Up @@ -762,6 +884,17 @@ const PROPOSAL_QUERY = `
dao {
details_daoName_n
}
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
}
}
suspend {
... on Role {
ballot_expiration_t
Expand Down Expand Up @@ -836,7 +969,10 @@ const PROPOSAL_QUERY = `
}
... on Votable {
votetally {
docId
... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
Expand Down Expand Up @@ -910,28 +1046,6 @@ export default {
},
apollo: {
upvoteElectionQuery: {
query: require('~/query/upvote-election-data.gql'),
update: data => {
return {
currentRound: data.getDao.ongoingelct[0]?.currentround[0].details_type_s,
nextRound: data.getDao.ongoingelct[0]?.currentround[0].nextround,
upcomingElection: data.getDao.upcomingelct
}
},
variables () {
return {
daoName: this.selectedDao.name
}
},
result (data) {
this.upvoteElectionData = {
currentRound: data.data.getDao.ongoingelct[0]?.currentround[0].details_type_s,
nextRound: data.data.getDao.ongoingelct[0]?.currentround[0].nextround,
upcomingElection: data.data.getDao.upcomingelct
}
}
},
proposal: {
query: gql`query proposalDetail($docId: String!) { ${PROPOSAL_QUERY} }`,
Expand Down

0 comments on commit 6961e5d

Please sign in to comment.