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

Issue 25 gh projects imptovement infer tech from language and topics #94

Conversation

nkapolcs
Copy link
Contributor

@nkapolcs nkapolcs commented Mar 9, 2020

Issue #25
Currently GH project tech info in configurable by hand, but we could extend it so that it can auto-infer some things.

Changes:

  • fetch languages from github
  • create logic
  • display languages
  • write documentation for languages threshold

Preview:
Peek 2020-03-09 23-24

@nkapolcs nkapolcs self-assigned this Mar 9, 2020
@nkapolcs
Copy link
Contributor Author

nkapolcs commented Mar 9, 2020

For now, I display the same as the medium, but maybe we could use icons if you prefer.

Copy link
Collaborator

@gomorizsolt gomorizsolt left a comment

Choose a reason for hiding this comment

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

Left a few comments, overall looks good!

For now, I display the same as the medium, but maybe we could use icons if you prefer.

From my side, it's fine as-is for now.

@gomorizsolt
Copy link
Collaborator

On second thought, how about making the logic more "reactish"? :)

const [languageBadges, setLanguageBadges] = useState([]);

useEffect(() => {
   if (githubRepoLanguages.data) {
      const sum = Object.keys(githubRepoLanguages.data).reduce(...);

      // filter the badges according to the treshold
      const badges = // ...
      
      setLanguageBadges(badges);
   }
}, [githubRepoLanguages.data]);

Please make sure there's no infinite re-renders(because data points to a reference). If so, let's use useMemo().

@thisismydesign
Copy link
Member

For now, I display the same as the medium, but maybe we could use icons if you prefer.

This should follow the display setting.

@nkapolcs nkapolcs changed the title Issue 25 gh projects imptovement infer tech from language and topics [WIP] Issue 25 gh projects imptovement infer tech from language and topics Mar 11, 2020
@nkapolcs
Copy link
Contributor Author

On second thought, how about making the logic more "reactish"? :)

const [languageBadges, setLanguageBadges] = useState([]);

useEffect(() => {
   if (githubRepoLanguages.data) {
      const sum = Object.keys(githubRepoLanguages.data).reduce(...);

      // filter the badges according to the treshold
      const badges = // ...
      
      setLanguageBadges(badges);
   }
}, [githubRepoLanguages.data]);

Please make sure there's no infinite re-renders(because data points to a reference). If so, let's use useMemo().

Thanks for suggesting. Now I solved it with hooks.

Resolved by a72c1f4

@nkapolcs
Copy link
Contributor Author

For now, I display the same as the medium, but maybe we could use icons if you prefer.

This should follow the display setting.

Resolved by a72c1f4

Copy link
Collaborator

@gomorizsolt gomorizsolt left a comment

Choose a reason for hiding this comment

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

I don't really get the logic inside of useEffect(), left a few questions.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@nkapolcs nkapolcs changed the title [WIP] Issue 25 gh projects imptovement infer tech from language and topics Issue 25 gh projects imptovement infer tech from language and topics Mar 21, 2020
src/components/Projects/utils/GithubUtils.js Outdated Show resolved Hide resolved
src/components/Projects/utils/GithubUtils.js Outdated Show resolved Hide resolved
@nkapolcs
Copy link
Contributor Author

nkapolcs commented Mar 25, 2020

How about making this even simpler?

const languages = Object.keys(githubRepoLanguages.data).filter(
    language => {
        const currentNumberOfBytes = githubRepoLanguages.data[language];

        return (
            (currentNumberOfBytes / sumOfNumberOfBytesOfLanguages) * 100 >
            threshold
        );
    }
);

This way you don't need to iterate over the array twice.

Thanks!

Resolved by 0d74fcc

@nkapolcs nkapolcs merged commit a40d197 into master Mar 26, 2020
@nkapolcs nkapolcs deleted the issue-25_gh-projects-imptovement-infer-tech-from-language-and-topics branch March 26, 2020 12:45
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.

3 participants