The language distribution calculation for pinned repositories is not working as expected. When trying to get the language distribution for pinned repos, the result is an empty array.
Example of the issue:
const { getRepositories } = useGitHub({ username: 'octocat' });
// Works correctly
console.log(getRepositories().all().languageDistribution());
// Output: [{ language: 'javascript', percentage: 0.5 }, { language: 'python', percentage: 0.5 }]
// Returns an empty array
console.log(getRepositories().pinned().languageDistribution());
// Output: []
Possible cause: The GraphQL query for pinned repos only fetches primaryLanguage, but the calculateLanguageDistribution function expects a language property.
Possible fix can be something like,
const pinnedRepos = response.data.data.user.pinnedItems.nodes.map(
(repo: any) => ({
// ... other properties ...
language: repo.primaryLanguage
? repo.primaryLanguage.name.toLowerCase()
: null,
}),
);
This change should make the pinned repos data structure compatible with the language distribution function.
The language distribution calculation for pinned repositories is not working as expected. When trying to get the language distribution for pinned repos, the result is an empty array.
Example of the issue:
Possible cause: The GraphQL query for pinned repos only fetches
primaryLanguage, but thecalculateLanguageDistributionfunction expects alanguageproperty.Possible fix can be something like,
This change should make the pinned repos data structure compatible with the language distribution function.