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: wrong counts #964

Merged
merged 2 commits into from
Dec 20, 2024
Merged

fix: wrong counts #964

merged 2 commits into from
Dec 20, 2024

Conversation

ChaituVR
Copy link
Member

Fixes https://github.com/snapshot-labs/workflow/issues/341

Summary:

Inside loadSpacesMetrics, we were using previous counts if metrics doesn't contain certain properties

spacesMetadata[space].counts = {
    ...spacesMetadata[space].counts,
    ...metrics
};
  • If there are no active proposals then getProposals return an object without activeProposals property
  • If there are no active proposals / recent proposals, then getProposals returns empty object
  • In these cases, it will show previous counts
  • This PR fixes that and uses new counts

How to test:

  • Create a proposal that ends in 5 mins
  • Try the following query
{
  space(id: "thanku.eth") {
    id
    activeProposals
    proposalsCount1d
    proposalsCount7d
    proposalsCount30d
  }
}
  • activeProposals should be 1
  • Once the proposal end activeProposals should be 0

@ChaituVR ChaituVR requested review from Copilot, wa0x6e and bonustrack and removed request for Copilot and wa0x6e December 19, 2024 12:05

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/helpers/spaces.ts:269

  • The current implementation overwrites the entire counts object, potentially losing other count properties that are not included in the metrics. Consider merging the new metrics with the existing counts object to preserve all properties.
spacesMetadata[space].counts = {
src/helpers/spaces.ts Outdated Show resolved Hide resolved
@ChaituVR ChaituVR requested a review from bonustrack December 20, 2024 08:45
Copy link
Member

@bonustrack bonustrack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@ChaituVR ChaituVR merged commit 2abe545 into master Dec 20, 2024
2 checks passed
@ChaituVR ChaituVR deleted the fix-wrong-counts branch December 20, 2024 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants