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

fix: Improve performance of validators query #131

Merged
merged 1 commit into from
Sep 18, 2024
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
2 changes: 1 addition & 1 deletion src/components/proposals/ProposalWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const { getProposal, getParams, getProposalTallies, getStakingStatus, getVotesAs
const { validators, getVotingPower } = useValidators(props.height != 0 ? props.height.toString() : undefined);
const validatorsWithStakeAndVotes = ref<
Array<
(ValidatorsQuery["validator_status"][0] | ValSetQuery["proposal_validator_status_snapshot"][0]) & {
(ValidatorsQuery["block"][0]["validator_statuses"][0] | ValSetQuery["proposal_validator_status_snapshot"][0]) & {
voting_power: number;
votes: VotesQuery["proposal_vote"];
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/proposals/ValidatorBreakdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as Utility from "@/utility/index";

const props = defineProps<{
validatorData: Array<
(ValidatorsQuery["validator_status"][0] | ValSetQuery["proposal_validator_status_snapshot"][0]) & {
(ValidatorsQuery["block"][0]["validator_statuses"][0] | ValSetQuery["proposal_validator_status_snapshot"][0]) & {
voting_power: number;
votes: VotesQuery["proposal_vote"];
}
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useValidators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const useValidators = (height?: string) => {
if (validatorList.value) {
return "proposal_validator_status_snapshot" in validatorList.value
? validatorList.value.proposal_validator_status_snapshot
: validatorList.value.validator_status;
: validatorList.value.block[0].validator_statuses;
} else {
return [];
}
Expand Down
4 changes: 2 additions & 2 deletions src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const documents = {
"query ProposalsSearch($limit: Int!, $offset: Int!, $searchString: String!) {\n all_proposals: proposal(\n order_by: [{active_first_order: asc}, {id: desc}]\n limit: $limit\n offset: $offset\n where: {_or: [{title: {_ilike: $searchString}}, {description: {_ilike: $searchString}}]}\n ) {\n content\n deposit_end_time\n description\n id\n proposal_type\n proposal_deposits {\n amount\n depositor_address\n }\n proposal_votes_aggregate(where: {is_valid: {_eq: true}}) {\n aggregate {\n count\n }\n }\n proposer_address\n status\n submit_time\n title\n voting_end_time\n voting_start_time\n }\n proposal_aggregate(\n where: {_or: [{title: {_ilike: $searchString}}, {description: {_ilike: $searchString}}]}\n ) {\n aggregate {\n count\n }\n }\n}": types.ProposalsSearchDocument,
"query Staking {\n staking_pool(order_by: {height: desc_nulls_last}) {\n bonded_tokens\n height\n not_bonded_tokens\n }\n}": types.StakingDocument,
"query ValSet($height: bigint!) {\n proposal_validator_status_snapshot: validator_status(\n distinct_on: validator_address\n order_by: {validator_address: asc, height: desc_nulls_last}\n where: {height: {_eq: $height}}\n ) {\n height\n jailed\n status\n validator_address\n validator_info {\n self_delegate_address\n validator_descriptions {\n identity\n avatar_url\n details\n moniker\n website\n }\n }\n }\n}": types.ValSetDocument,
"query Validators {\n validator_status(\n distinct_on: validator_address\n order_by: {validator_address: asc, height: desc_nulls_last}\n ) {\n height\n jailed\n status\n validator_address\n validator_info {\n self_delegate_address\n validator_descriptions {\n identity\n avatar_url\n details\n moniker\n website\n }\n }\n }\n}": types.ValidatorsDocument,
"query Validators {\n block(limit: 1, order_by: {height: desc_nulls_last}) {\n height\n validator_statuses(order_by: {validator_address: asc}) {\n height\n jailed\n status\n validator_address\n validator_info {\n self_delegate_address\n validator_descriptions {\n identity\n avatar_url\n details\n moniker\n website\n }\n }\n }\n }\n}": types.ValidatorsDocument,
"query VoteHistory($address: String!) {\n proposal_vote(\n where: {voter_address: {_eq: $address}, _and: {is_valid: {_eq: true}}}\n ) {\n option\n weight\n height\n voter_address\n proposal_id\n is_valid\n }\n}": types.VoteHistoryDocument,
"query VoteOption($proposalId: Int!, $option: String!) {\n proposal_vote_aggregate(\n where: {_and: {is_valid: {_eq: true}, proposal_id: {_eq: $proposalId}, option: {_eq: $option}}}\n ) {\n aggregate {\n count\n }\n }\n}": types.VoteOptionDocument,
"query Votes($address: String!, $proposalId: Int!, $propId: String!) {\n proposal_vote(\n where: {proposal_id: {_eq: $proposalId}, voter_address: {_eq: $address}}\n order_by: {height: desc}\n ) {\n voter_address\n option\n height\n proposal_id\n timestamp\n weight\n block {\n transactions(\n where: {messages: {_contains: [{proposal_id: $propId, voter: $address}]}}\n ) {\n height\n hash\n memo\n success\n messages\n }\n }\n }\n}": types.VotesDocument,
Expand Down Expand Up @@ -111,7 +111,7 @@ export function graphql(source: "query ValSet($height: bigint!) {\n proposal_va
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "query Validators {\n validator_status(\n distinct_on: validator_address\n order_by: {validator_address: asc, height: desc_nulls_last}\n ) {\n height\n jailed\n status\n validator_address\n validator_info {\n self_delegate_address\n validator_descriptions {\n identity\n avatar_url\n details\n moniker\n website\n }\n }\n }\n}"): (typeof documents)["query Validators {\n validator_status(\n distinct_on: validator_address\n order_by: {validator_address: asc, height: desc_nulls_last}\n ) {\n height\n jailed\n status\n validator_address\n validator_info {\n self_delegate_address\n validator_descriptions {\n identity\n avatar_url\n details\n moniker\n website\n }\n }\n }\n}"];
export function graphql(source: "query Validators {\n block(limit: 1, order_by: {height: desc_nulls_last}) {\n height\n validator_statuses(order_by: {validator_address: asc}) {\n height\n jailed\n status\n validator_address\n validator_info {\n self_delegate_address\n validator_descriptions {\n identity\n avatar_url\n details\n moniker\n website\n }\n }\n }\n }\n}"): (typeof documents)["query Validators {\n block(limit: 1, order_by: {height: desc_nulls_last}) {\n height\n validator_statuses(order_by: {validator_address: asc}) {\n height\n jailed\n status\n validator_address\n validator_info {\n self_delegate_address\n validator_descriptions {\n identity\n avatar_url\n details\n moniker\n website\n }\n }\n }\n }\n}"];
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
Expand Down
Loading
Loading