Skip to content

Commit

Permalink
improve gov query performance
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Apr 17, 2024
1 parent 3df328c commit 5e8ea05
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ const InnerComponent: ActionComponent<undefined, GovernanceDepositData> = (
? govProposalsSelector({
status: ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD,
chainId,
limit: 100,
// No need to load more than 50 proposals when trying to find
// proposals currently being voted on. The alternative is to load all
// proposals, which is not ideal. Ideally, this is pre-indexed and we
// can query only the proposals in the voting period instead of having
// to filter locally.
limit: 50,
})
: constSelector(undefined)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ const Component: ActionComponent<undefined, GovernanceVoteData> = (props) => {
? govProposalsSelector({
status: ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD,
chainId,
limit: 100,
// No need to load more than 50 proposals when trying to find
// proposals currently being voted on. The alternative is to load all
// proposals, which is not ideal. Ideally, this is pre-indexed and we
// can query only the proposals in the voting period instead of having
// to filter locally.
limit: 50,
})
: constSelector(undefined)
)
Expand Down
10 changes: 10 additions & 0 deletions packages/stateful/components/gov/GovProposalList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export const GovProposalList = () => {
govProposalsSelector({
chainId: chain.chain_id,
status: ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD,
// No need to load more than 50 proposals when trying to find proposals
// currently being voted on. The alternative is to load all proposals,
// which is not ideal. Ideally, this is pre-indexed and we can query only
// the proposals in the voting period instead of having to filter locally.
limit: 50,
}),
{
proposals: [],
Expand All @@ -35,6 +40,11 @@ export const GovProposalList = () => {
govProposalsSelector({
chainId: chain.chain_id,
status: ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD,
// No need to load more than 50 proposals when trying to find proposals in
// the deposit period. The alternative is to load all proposals, which is
// not ideal. Ideally, this is pre-indexed and we can query only the
// proposals in the voting period instead of having to filter locally.
limit: 50,
}),
{
proposals: [],
Expand Down

0 comments on commit 5e8ea05

Please sign in to comment.