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

Draft: Add sponsorability feature #135

Open
wants to merge 135 commits into
base: main
Choose a base branch
from
Open

Conversation

IngridGdesigns
Copy link
Collaborator

Work in progress

Copy link
Collaborator

@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.

public async fetchSponsorabilityInformation(
token: string,
repositoryIdentifiers: string[]
): Promise<Map<string, ContributionCountOfUserIntoRepo[]>> {
Copy link
Collaborator

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.

repositoryIdentifiers: string[]
): Promise<Map<string, ContributionCountOfUserIntoRepo[]>> {
//SponsorWithRepoIdAndContribution
const fetchAllContributors = new ContributorFetcher(this.config);
Copy link
Collaborator

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
Collaborator 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

await sponsorableContributorsFetcher.fetchSponsorableContributorsInformation(
token,
queryTemplate,
allContributorHistorys
Copy link
Collaborator

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
Collaborator 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[],

allContributorHistorys
);

const sponsorableContributorWithContributonCounts =
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this step

});
}

return sponsorables;
Copy link
Collaborator

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
Collaborator Author

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

contributor: SponsorableWithContributionCount;
}[] = [];

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

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.


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

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.


/*

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

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
Collaborator 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

const allSponsorableUsersInfo = [];
const sponsorables = new Map<string, Sponsor[]>();

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

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);

}
}

// need to refactor:
Copy link
Collaborator

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
Collaborator 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.

None yet

2 participants