You've already forked wakapi-readme-stats
Merge pull request #146 from aaditkamat/filter-commit-author
fix: filter commits by author for loc calculation
This commit is contained in:
19
loc.py
19
loc.py
@@ -56,24 +56,23 @@ class LinesOfCode:
|
|||||||
return 3
|
return 3
|
||||||
elif month >= 10 and month <= 12:
|
elif month >= 10 and month <= 12:
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
def getCommitStat(self, repoDetails, yearly_data):
|
def getCommitStat(self, repoDetails, yearly_data):
|
||||||
allCommitsEndPoint = 'https://api.github.com/repos/' + repoDetails['nameWithOwner'] + '/commits'
|
commitsURL = 'https://api.github.com/repos/' + repoDetails['nameWithOwner'] + '/commits'
|
||||||
allCommitsResult = self.run_query_v3(allCommitsEndPoint)
|
filteredCommitsEndPoint = commitsURL + '?author=' + self.username
|
||||||
|
filteredCommitsResult = self.run_query_v3(filteredCommitsEndPoint)
|
||||||
# This ignores the error message you get when you try to list commits for an empty repository
|
# This ignores the error message you get when you try to list commits for an empty repository
|
||||||
if not type(allCommitsResult) == list:
|
if not type(filteredCommitsResult) == list:
|
||||||
return
|
return
|
||||||
this_year = datetime.datetime.utcnow().year
|
this_year = datetime.datetime.utcnow().year
|
||||||
|
|
||||||
for i in range(len(allCommitsResult)):
|
for i in range(len(filteredCommitsResult)):
|
||||||
author = allCommitsResult[i]["commit"]["author"]
|
iso_date = filteredCommitsResult[i]["commit"]["author"]["date"]
|
||||||
if author["name"] != self.username:
|
date = re.search(r'\d+-\d+-\d+', iso_date).group(0)
|
||||||
continue
|
|
||||||
date = re.search(r'\d+-\d+-\d+', author["date"]).group(0)
|
|
||||||
curr_year = datetime.datetime.fromisoformat(date).year
|
curr_year = datetime.datetime.fromisoformat(date).year
|
||||||
# if curr_year != this_year:
|
# if curr_year != this_year:
|
||||||
|
|
||||||
individualCommitEndPoint = allCommitsResult[i]["url"]
|
individualCommitEndPoint = commitsURL + '/' + filteredCommitsResult[i]["sha"]
|
||||||
individualCommitResult = self.run_query_v3(individualCommitEndPoint)
|
individualCommitResult = self.run_query_v3(individualCommitEndPoint)
|
||||||
|
|
||||||
quarter = self.getQuarter(date)
|
quarter = self.getQuarter(date)
|
||||||
|
|||||||
Reference in New Issue
Block a user