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

Contribution Count Shows Different Numbers - fixed #443 #460

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 app/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const DefaultForageConfig: LocalForageConfig = {
// this store should be used for any on-chain/off-chain data but never user data (as we might clear it without notice)
name: 'dGrants',
// we can bump this version number to bust the users cache
version: 1,
version: 3,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 3 and not 2?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't sure what should I put, thought maybe some other PR is going to use 2.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are no other open PRs changing this, so we should use 2 🙂

Suggested change
version: 3,
version: 2,

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

};

// LocalForage keys
Expand Down
5 changes: 3 additions & 2 deletions app/src/utils/data/contributions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function getContributions(

const limit = 100;

const fetchUntilAll = async (SUBGRAPH_URL: string, before = [], skip = 0): Promise<any[]> => {
const fetchUntilAll = async (SUBGRAPH_URL: string, before: any[] = [], skip = 0): Promise<any[]> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we should have stronger typing than any, but we can save that for the PR that handles #463

Copy link
Member Author

Choose a reason for hiding this comment

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

Now we use type ContributionSubgraph instead of any.

const res = await fetch(SUBGRAPH_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
Expand All @@ -80,7 +80,8 @@ export async function getContributions(
const json = await res.json();

if (json.data.grantDonations.length) {
return await fetchUntilAll(SUBGRAPH_URL, before, skip + 1);
const current = [...before, ...json.data.grantDonation];
return await fetchUntilAll(SUBGRAPH_URL, current, skip + 1);
} else {
return [...before];
}
Expand Down