add ignored repos

This commit is contained in:
Roc136
2021-05-06 22:31:51 +08:00
parent 549731c9c0
commit 92e9cd44a0
4 changed files with 15 additions and 5 deletions

View File

@@ -233,6 +233,8 @@ CSS 2 repos █░░░░░░░░░░░░░░░░
`SHOW_LOC_CHART` flag can be set to `False` to hide the Lines of code written in different quarters of different year `SHOW_LOC_CHART` flag can be set to `False` to hide the Lines of code written in different quarters of different year
`IGNORED_REPOS` flag can be set to `"waka-readme-stats, my-first-repo"` (just an example) to ignore some repos you dont want to be counted
**Timeline** **Timeline**
![Chart not found](https://raw.githubusercontent.com/anmol098/anmol098/master/charts/bar_graph.png) ![Chart not found](https://raw.githubusercontent.com/anmol098/anmol098/master/charts/bar_graph.png)

View File

@@ -82,6 +82,11 @@ inputs:
description: "Git commit with your own name and email" description: "Git commit with your own name and email"
default: "False" default: "False"
IGNORED_REPOS:
required: false
description: "Repos you don't want to be counted"
default: ""
runs: runs:
using: 'docker' using: 'docker'
image: 'Dockerfile' image: 'Dockerfile'

4
loc.py
View File

@@ -15,18 +15,20 @@ from make_bar_graph import BarGraph
class LinesOfCode: class LinesOfCode:
def __init__(self, id, username, ghtoken, repositoryData): def __init__(self, id, username, ghtoken, repositoryData, ignored_repos):
self.id = id self.id = id
self.username = username self.username = username
self.g = Github(ghtoken) self.g = Github(ghtoken)
self.headers = {"Authorization": "Bearer " + ghtoken} self.headers = {"Authorization": "Bearer " + ghtoken}
self.repositoryData = repositoryData self.repositoryData = repositoryData
self.ignored_repos = ignored_repos
def calculateLoc(self): def calculateLoc(self):
result = self.repositoryData result = self.repositoryData
yearly_data = {} yearly_data = {}
for repo in result['data']['user']['repositories']['edges']: for repo in result['data']['user']['repositories']['edges']:
if repo['node']['name'] not in self.ignored_repos:
self.getCommitStat(repo['node'], yearly_data) self.getCommitStat(repo['node'], yearly_data)
time.sleep(0.7) time.sleep(0.7)
return yearly_data return yearly_data

View File

@@ -42,6 +42,7 @@ show_profile_view = os.getenv('INPUT_SHOW_PROFILE_VIEWS')
show_short_info = os.getenv('INPUT_SHOW_SHORT_INFO') show_short_info = os.getenv('INPUT_SHOW_SHORT_INFO')
locale = os.getenv('INPUT_LOCALE') locale = os.getenv('INPUT_LOCALE')
commit_by_me = os.getenv('INPUT_COMMIT_BY_ME') commit_by_me = os.getenv('INPUT_COMMIT_BY_ME')
ignored_repos_name = str(os.getenv('INPUT_IGNORED_REPOS') or '').replace(' ', '').split(',')
show_waka_stats = 'y' show_waka_stats = 'y'
# The GraphQL query to get commit data. # The GraphQL query to get commit data.
userInfoQuery = """ userInfoQuery = """
@@ -387,7 +388,7 @@ def generate_language_per_repo(result):
def get_line_of_code(): def get_line_of_code():
repositoryList = run_query(repositoryListQuery.substitute(username=username, id=id)) repositoryList = run_query(repositoryListQuery.substitute(username=username, id=id))
loc = LinesOfCode(id, username, ghtoken, repositoryList) loc = LinesOfCode(id, username, ghtoken, repositoryList, ignored_repos_name)
yearly_data = loc.calculateLoc() yearly_data = loc.calculateLoc()
total_loc = sum([yearly_data[year][quarter][lang] for year in yearly_data for quarter in yearly_data[year] for lang in yearly_data[year][quarter]]) total_loc = sum([yearly_data[year][quarter][lang] for year in yearly_data for quarter in yearly_data[year] for lang in yearly_data[year][quarter]])
return humanize.intword(int(total_loc)) return humanize.intword(int(total_loc))
@@ -453,7 +454,7 @@ def get_stats(github):
stats = stats + generate_language_per_repo(repositoryList) + '\n\n' stats = stats + generate_language_per_repo(repositoryList) + '\n\n'
if showLocChart.lower() in truthy: if showLocChart.lower() in truthy:
loc = LinesOfCode(id, username, ghtoken, repositoryList) lloc = LinesOfCode(id, username, ghtoken, repositoryList, ignored_repos_name)
yearly_data = loc.calculateLoc() yearly_data = loc.calculateLoc()
loc.plotLoc(yearly_data) loc.plotLoc(yearly_data)
stats += '**' + translate['Timeline'] + '**\n\n' stats += '**' + translate['Timeline'] + '**\n\n'