Skip to content
This repository was archived by the owner on Aug 16, 2023. It is now read-only.

Draft: Add sponsorability feature#135

Open
IngridGdesigns wants to merge 135 commits into
mainfrom
addSponsorabilityInfo
Open

Draft: Add sponsorability feature#135
IngridGdesigns wants to merge 135 commits into
mainfrom
addSponsorabilityInfo

Conversation

@IngridGdesigns
Copy link
Copy Markdown
Contributor

Work in progress

Comment thread src/sponsorabilityFetcher.ts Outdated
Copy link
Copy Markdown
Contributor

@kevindigo kevindigo left a comment

Choose a reason for hiding this comment

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

Let's discuss in slack or in a video call.

Comment thread src/sponsorabilityFinder.ts Outdated
public async fetchSponsorabilityInformation(
token: string,
repositoryIdentifiers: string[]
): Promise<Map<string, ContributionCountOfUserIntoRepo[]>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I would expect the return value from this function to be an array, where each entry contains all of the data for one row of the spreadsheet.

Comment thread src/sponsorabilityFinder.ts Outdated
repositoryIdentifiers: string[]
): Promise<Map<string, ContributionCountOfUserIntoRepo[]>> {
//SponsorWithRepoIdAndContribution
const fetchAllContributors = new ContributorFetcher(this.config);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The name should be a noun, like contributorFetcher. Or, since later we learn that it's returning histories, maybe the class should be ContributorHistoryFetcher and this const should be contributorHistoryFetcher?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not wild about the names but will change it

Comment thread src/sponsorabilityFinder.ts Outdated
await sponsorableContributorsFetcher.fetchSponsorableContributorsInformation(
token,
queryTemplate,
allContributorHistorys
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generally it would be better to only pass in the needed information. In this case, passing just a simple list of contributors (without history).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok, passed it in to have the key of Contributor[],

Comment thread src/sponsorabilityFinder.ts Outdated
allContributorHistorys
);

const sponsorableContributorWithContributonCounts =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like this step

Comment thread src/sponsorableContributorsFetcher.ts Outdated
});
}

return sponsorables;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we already have a map of contributors by repo from elsewhere, does this need to tie the sponsorables back to their repos? Could this just return an array of Sponsors? (Which I would rename Sponsorable, since these are the people potentially being sponsored, not the people doing the sponsoring.)

Copy link
Copy Markdown
Contributor Author

@IngridGdesigns IngridGdesigns Mar 16, 2023

Choose a reason for hiding this comment

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

will work returning array, rename interface to Sponsorables

Comment thread src/sponsorabilityFinder.ts Outdated
contributor: SponsorableWithContributionCount;
}[] = [];

for (const [key, sponsors] of sponsorableContributor) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be clearer to rename key to repoId. And sponsors should be sponsorables.

Comment thread src/sponsorabilityFinder.ts Outdated

public addContributionCount(
sponsorableContributor: Map<string, Sponsor[]>,
contributors: ContributionCountOfUserIntoRepo[]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should probably be something like contributionCounts. I'm not sure that's right, but it's at least closer.

Comment thread src/sponsorabilityFinder.ts Outdated

/*

for each repo count the number of contributions that were made,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

More of this kind of comment might be helpful while the naming and logic is still being worked out. Then, by the end, hopefully the code will be clear enough that the comments will be redundant and can be deleted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, planning to remove all comments once my logic and naming is fleshed out

Comment thread src/sponsorableContributorsFetcher.ts Outdated
const allSponsorableUsersInfo = [];
const sponsorables = new Map<string, Sponsor[]>();

for (const [repoIdentifier, githubUsers] of contributors.entries()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To avoid dealing with "entries", I would typically have this outer loop iterate through just the "keys". Then the first line inside the loop would be const users = contributors.get(repoIdentifier);

Comment thread src/sponsorableContributorsFetcher.ts Outdated
}
}

// need to refactor:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suspect this would be simpler if you built the map inside the loop above, instead of building it there an array, and then converting it to a map here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was having issues trying to do that inside the loop, (was getting duplicates)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants