From 6961e5d36d1bc17b93605eabbc01c3ff7ffb6d74 Mon Sep 17 00:00:00 2001 From: Arsenije Savic Date: Wed, 20 Sep 2023 08:26:32 -0600 Subject: [PATCH] refactor(proposal-detail): add votetally to each doc --- src/components/proposals/voter-list.vue | 33 +++-- src/pages/proposals/ProposalDetail.vue | 158 ++++++++++++++++++++---- 2 files changed, 152 insertions(+), 39 deletions(-) diff --git a/src/components/proposals/voter-list.vue b/src/components/proposals/voter-list.vue index 369083f17..5352d51be 100644 --- a/src/components/proposals/voter-list.vue +++ b/src/components/proposals/voter-list.vue @@ -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 { @@ -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 { @@ -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} }`, diff --git a/src/pages/proposals/ProposalDetail.vue b/src/pages/proposals/ProposalDetail.vue index 9de80b82a..482fdd184 100644 --- a/src/pages/proposals/ProposalDetail.vue +++ b/src/pages/proposals/ProposalDetail.vue @@ -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 @@ -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 @@ -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 } @@ -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 @@ -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 @@ -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 { @@ -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 } @@ -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 { @@ -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 @@ -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 } @@ -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 @@ -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 { @@ -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 @@ -836,7 +969,10 @@ const PROPOSAL_QUERY = ` } ... on Votable { votetally { + docId + ... on VoteTally { + docId pass_votePower_a fail_votePower_a abstain_votePower_a @@ -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} }`,