Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(proposal-detail): add votetally to each doc #2467

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}

start {
details_startTime_t
}
Expand Down Expand Up @@ -223,6 +254,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 @@ -282,6 +323,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 @@ -336,6 +387,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 @@ -414,6 +475,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 @@ -455,6 +526,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 @@ -548,6 +629,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 @@ -633,6 +725,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 @@ -702,6 +804,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 @@ -724,6 +836,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 @@ -773,6 +895,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 @@ -847,7 +980,10 @@ const PROPOSAL_QUERY = `
}
... on Votable {
votetally {
docId

... on VoteTally {
docId
pass_votePower_a
fail_votePower_a
abstain_votePower_a
Expand Down Expand Up @@ -921,28 +1057,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
Loading