Skip to content

Commit

Permalink
Merge branch 'master' into border-fix (anuraghazra#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrieb committed Feb 9, 2021
2 parents 12b6610 + e552808 commit 7885fa9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@ For more information on inaccuracies, see issue
to the "Secrets" page (bottom left).
4. Create a new secret with the name `ACCESS_TOKEN` and paste the copied
personal access token as the value.
5. If you want to ignore certain repos, add them (separated by commas) to a new
secret—created as before—called `EXCLUDED`. If you want to ignore certain
languages, add them (separated by commas) to a new secret called
`EXCLUDED_LANGS`.
5. It is possible to change the type of statistics reported.
- To ignore certain repos, add them (separated by commas) to a new
secret—created as before—called `EXCLUDED`.
- To ignore certain languages, add them (separated by commas) to a new
secret called `EXCLUDED_LANGS`.
- To show statistics only for "owned" repositories and not forks with
contributions, add an environment variable (under the `env` header in the
[main
workflow](https://github.com/jstrieb/github-stats/blob/master/.github/workflows/main.yml))
called `EXCLUDE_FORKED_REPOS` with a value of `true`.
6. Go to the [Actions
Page](../../actions?query=workflow%3A"Generate+Stats+Images") and press "Run
Workflow" on the right side of the screen to generate images for the first
Expand Down
6 changes: 4 additions & 2 deletions generate_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ async def main() -> None:
exclude_langs = os.getenv("EXCLUDED_LANGS")
exclude_langs = ({x.strip() for x in exclude_langs.split(",")}
if exclude_langs else None)
# Convert a truthy value to a Boolean
ignore_forked_repos = not not os.getenv("EXCLUDE_FORKED_REPOS")
async with aiohttp.ClientSession() as session:
s = Stats(user, access_token, session, exclude_repos=exclude_repos,
exclude_langs=exclude_langs)
exclude_langs=exclude_langs,
ignore_forked_repos=ignore_forked_repos)
await asyncio.gather(generate_languages(s), generate_overview(s))


if __name__ == "__main__":
asyncio.run(main())
8 changes: 4 additions & 4 deletions generated/overview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions github_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ class Stats(object):
def __init__(self, username: str, access_token: str,
session: aiohttp.ClientSession,
exclude_repos: Optional[Set] = None,
exclude_langs: Optional[Set] = None):
exclude_langs: Optional[Set] = None,
ignore_forked_repos: bool = False):
self.username = username
self._ignore_forked_repos = ignore_forked_repos
self._exclude_repos = set() if exclude_repos is None else exclude_repos
self._exclude_langs = set() if exclude_langs is None else exclude_langs
self.queries = Queries(username, access_token, session)
Expand Down Expand Up @@ -304,8 +306,10 @@ async def get_stats(self) -> None:
.get("data", {})
.get("viewer", {})
.get("repositories", {}))
repos = (contrib_repos.get("nodes", [])
+ owned_repos.get("nodes", []))

repos = owned_repos.get("nodes", [])
if not self._ignore_forked_repos:
repos += contrib_repos.get("nodes", [])

for repo in repos:
name = repo.get("nameWithOwner")
Expand Down

0 comments on commit 7885fa9

Please sign in to comment.