You've already forked wakapi-readme-stats
FEAT: ADDED NEW MODULES
This commit is contained in:
7
loc.py
7
loc.py
@@ -27,12 +27,8 @@ class LinesOfCode:
|
|||||||
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']:
|
||||||
print(repo)
|
|
||||||
self.getCommitStat(repo['node'], yearly_data)
|
self.getCommitStat(repo['node'], yearly_data)
|
||||||
time.sleep(0.7)
|
time.sleep(0.7)
|
||||||
# print("\n\n")
|
|
||||||
# print(yearly_data)
|
|
||||||
# print("here")
|
|
||||||
graph = BarGraph(yearly_data)
|
graph = BarGraph(yearly_data)
|
||||||
graph_file = graph.build_graph()
|
graph_file = graph.build_graph()
|
||||||
self.pushChart()
|
self.pushChart()
|
||||||
@@ -89,6 +85,3 @@ class LinesOfCode:
|
|||||||
repo.update_file(contents.path, "Charts Added", data, contents.sha)
|
repo.update_file(contents.path, "Charts Added", data, contents.sha)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
repo.create_file("charts/bar_graph.png", "Initial Commit", data)
|
repo.create_file("charts/bar_graph.png", "Initial Commit", data)
|
||||||
# print("pushed")
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
20
main.py
20
main.py
@@ -1,11 +1,9 @@
|
|||||||
'''
|
'''
|
||||||
Readme Development Metrics With waka time progress
|
Readme Development Metrics With waka time progress
|
||||||
'''
|
'''
|
||||||
import locale
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import base64
|
import base64
|
||||||
import sys
|
|
||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
import pytz
|
import pytz
|
||||||
import requests
|
import requests
|
||||||
@@ -28,8 +26,8 @@ showCommit = os.getenv('INPUT_SHOW_COMMIT')
|
|||||||
showLanguage = os.getenv('INPUT_SHOW_LANGUAGE')
|
showLanguage = os.getenv('INPUT_SHOW_LANGUAGE')
|
||||||
show_loc = os.getenv('INPUT_SHOW_LINES_OF_CODE')
|
show_loc = os.getenv('INPUT_SHOW_LINES_OF_CODE')
|
||||||
|
|
||||||
showLanguagePerRepo = 'y' if os.getenv('INPUT_SHOW_LANGUAGE_PER_REPO') is None else os.getenv('INPUT_SHOW_LANGUAGE_PER_REPO')
|
showLanguagePerRepo = os.getenv('INPUT_SHOW_LANGUAGE_PER_REPO')
|
||||||
showLocChart = 'y' if os.getenv('INPUT_SHOW_LOC_CHART') is None else os.getenv('INPUT_SHOW_LOC_CHART')
|
showLocChart = os.getenv('INPUT_SHOW_LOC_CHART')
|
||||||
show_waka_stats = 'y'
|
show_waka_stats = 'y'
|
||||||
# The GraphQL query to get commit data.
|
# The GraphQL query to get commit data.
|
||||||
userInfoQuery = """
|
userInfoQuery = """
|
||||||
@@ -288,7 +286,6 @@ def generate_commit_list(tz):
|
|||||||
return string
|
return string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_waka_time_stats():
|
def get_waka_time_stats():
|
||||||
stats = ''
|
stats = ''
|
||||||
request = requests.get(
|
request = requests.get(
|
||||||
@@ -301,8 +298,8 @@ def get_waka_time_stats():
|
|||||||
stats = stats + '📊 **This week I spent my time on** \n\n'
|
stats = stats + '📊 **This week I spent my time on** \n\n'
|
||||||
stats = stats + '```text\n'
|
stats = stats + '```text\n'
|
||||||
if showTimeZone.lower() in ['true', '1', 't', 'y', 'yes']:
|
if showTimeZone.lower() in ['true', '1', 't', 'y', 'yes']:
|
||||||
timezone = data['data']['timezone']
|
tzone = data['data']['timezone']
|
||||||
stats = stats + '⌚︎ Timezone: ' + timezone + '\n\n'
|
stats = stats + '⌚︎ Timezone: ' + tzone + '\n\n'
|
||||||
|
|
||||||
if showLanguage.lower() in ['true', '1', 't', 'y', 'yes']:
|
if showLanguage.lower() in ['true', '1', 't', 'y', 'yes']:
|
||||||
if len(data['data']['languages']) != 0:
|
if len(data['data']['languages']) != 0:
|
||||||
@@ -378,11 +375,9 @@ def get_stats():
|
|||||||
stats = ''
|
stats = ''
|
||||||
repositoryList = run_query(repositoryListQuery.substitute(username=username, id=id))
|
repositoryList = run_query(repositoryListQuery.substitute(username=username, id=id))
|
||||||
|
|
||||||
|
|
||||||
if show_waka_stats.lower() in ['true', '1', 't', 'y', 'yes']:
|
if show_waka_stats.lower() in ['true', '1', 't', 'y', 'yes']:
|
||||||
stats = stats + get_waka_time_stats()
|
stats = stats + get_waka_time_stats()
|
||||||
|
|
||||||
|
|
||||||
if showLanguagePerRepo.lower() in ['true', '1', 't', 'y', 'yes']:
|
if showLanguagePerRepo.lower() in ['true', '1', 't', 'y', 'yes']:
|
||||||
stats = stats + generate_language_per_repo(repositoryList) + '\n\n'
|
stats = stats + generate_language_per_repo(repositoryList) + '\n\n'
|
||||||
|
|
||||||
@@ -390,9 +385,7 @@ def get_stats():
|
|||||||
loc = LinesOfCode(id, username, ghtoken, repositoryList)
|
loc = LinesOfCode(id, username, ghtoken, repositoryList)
|
||||||
loc.calculateLoc()
|
loc.calculateLoc()
|
||||||
stats = stats + '**Timeline**\n\n'
|
stats = stats + '**Timeline**\n\n'
|
||||||
stats = stats + ' \n\n'
|
stats = stats + ' \n\n'
|
||||||
# stats = stats + generate_language_per_repo(repositoryList) + '\n\n'
|
|
||||||
|
|
||||||
|
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
@@ -418,7 +411,6 @@ if __name__ == '__main__':
|
|||||||
user_data = run_query(userInfoQuery) # Execute the query
|
user_data = run_query(userInfoQuery) # Execute the query
|
||||||
username = user_data["data"]["viewer"]["login"]
|
username = user_data["data"]["viewer"]["login"]
|
||||||
id = user_data["data"]["viewer"]["id"]
|
id = user_data["data"]["viewer"]["id"]
|
||||||
# print("user {} id {}".format(username, id))
|
|
||||||
repo = g.get_repo(f"{username}/{username}")
|
repo = g.get_repo(f"{username}/{username}")
|
||||||
contents = repo.get_readme()
|
contents = repo.get_readme()
|
||||||
waka_stats = get_stats()
|
waka_stats = get_stats()
|
||||||
@@ -430,4 +422,4 @@ if __name__ == '__main__':
|
|||||||
content=new_readme, sha=contents.sha, branch='master')
|
content=new_readme, sha=contents.sha, branch='master')
|
||||||
print("Readme updated")
|
print("Readme updated")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Exception Occurred" + str(e))
|
print("Exception Occurred " + str(e))
|
||||||
|
|||||||
Reference in New Issue
Block a user