You've already forked wakapi-readme-stats
10
Dockerfile
10
Dockerfile
@@ -7,6 +7,12 @@ ADD loc.py /loc.py
|
||||
ADD make_bar_graph.py /make_bar_graph.py
|
||||
ADD colors.json /colors.json
|
||||
RUN pip install -r requirements.txt
|
||||
RUN npm install vega-lite vega-cli canvas
|
||||
|
||||
CMD ["python", "/main.py"]
|
||||
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
|
||||
|
||||
RUN npm -g config set user root
|
||||
|
||||
RUN npm install -g vega-lite vega-cli canvas
|
||||
|
||||
ENTRYPOINT ["python", "/main.py"]
|
||||
|
||||
|
||||
30
loc.py
30
loc.py
@@ -30,9 +30,9 @@ class LinesOfCode:
|
||||
print(repo)
|
||||
self.getCommitStat(repo['node'], yearly_data)
|
||||
time.sleep(0.7)
|
||||
print("\n\n")
|
||||
print(yearly_data)
|
||||
print("here")
|
||||
# print("\n\n")
|
||||
# print(yearly_data)
|
||||
# print("here")
|
||||
graph = BarGraph(yearly_data)
|
||||
graph_file = graph.build_graph()
|
||||
self.pushChart()
|
||||
@@ -89,28 +89,6 @@ class LinesOfCode:
|
||||
repo.update_file(contents.path, "Charts Added", data, contents.sha)
|
||||
except Exception as e:
|
||||
repo.create_file("charts/bar_graph.png", "Initial Commit", data)
|
||||
print("pushed")
|
||||
# print("pushed")
|
||||
|
||||
# if __name__ == '__main__':
|
||||
# try:
|
||||
# g = Github(ghtoken)
|
||||
# headers = {"Authorization": "Bearer " + ghtoken}
|
||||
# user_data = run_query(userInfoQuery) # Execute the query
|
||||
# username = user_data["data"]["viewer"]["login"]
|
||||
# id = user_data["data"]["viewer"]["id"]
|
||||
# print("user {} id {}".format(username, id))
|
||||
|
||||
# getLoc()
|
||||
|
||||
# # repo = g.get_repo(f"{username}/{username}")
|
||||
# # contents = repo.get_readme()
|
||||
# # waka_stats = get_stats()
|
||||
# # rdmd = decode_readme(contents.content)
|
||||
# # new_readme = generate_new_readme(stats=waka_stats, readme=rdmd)
|
||||
# # print(new_readme)
|
||||
# # # if new_readme != rdmd:
|
||||
# # repo.update_file(path=contents.path, message='Updated with Dev Metrics',
|
||||
# # content=new_readme, sha=contents.sha, branch='master')
|
||||
# # print("Readme updated")
|
||||
# except Exception as e:
|
||||
# print("Exception Occurred" + str(e))
|
||||
|
||||
39
main.py
39
main.py
@@ -21,19 +21,19 @@ START_COMMENT = '<!--START_SECTION:waka-->'
|
||||
END_COMMENT = '<!--END_SECTION:waka-->'
|
||||
listReg = f"{START_COMMENT}[\\s\\S]+{END_COMMENT}"
|
||||
|
||||
user = os.getenv('INPUT_USERNAME')
|
||||
waka_key = os.getenv('INPUT_WAKATIME_API_KEY')
|
||||
ghtoken = os.getenv('INPUT_GH_TOKEN')
|
||||
showTimeZone = os.getenv('INPUT_SHOW_TIMEZONE')
|
||||
showProjects = os.getenv('INPUT_SHOW_PROJECTS')
|
||||
showEditors = os.getenv('INPUT_SHOW_EDITORS')
|
||||
showOs = os.getenv('INPUT_SHOW_OS')
|
||||
showCommit = os.getenv('INPUT_SHOW_COMMIT')
|
||||
showLanguage = os.getenv('INPUT_SHOW_LANGUAGE')
|
||||
show_loc = os.getenv('INPUT_SHOW_LINES_OF_CODE')
|
||||
user = 'y' if os.getenv('INPUT_USERNAME') is None else os.getenv('INPUT_USERNAME')
|
||||
waka_key = 'y' if os.getenv('INPUT_WAKATIME_API_KEY') is None else os.getenv('INPUT_WAKATIME_API_KEY')
|
||||
ghtoken = 'y' if os.getenv('INPUT_GH_TOKEN') is None else os.getenv('INPUT_GH_TOKEN')
|
||||
showTimeZone = 'y' if os.getenv('INPUT_SHOW_TIMEZONE') is None else os.getenv('INPUT_SHOW_TIMEZONE')
|
||||
showProjects = 'y' if os.getenv('INPUT_SHOW_PROJECTS') is None else os.getenv('INPUT_SHOW_PROJECTS')
|
||||
showEditors = 'y' if os.getenv('INPUT_SHOW_EDITORS') is None else os.getenv('INPUT_SHOW_EDITORS')
|
||||
showOs = 'y' if os.getenv('INPUT_SHOW_OS') is None else os.getenv('INPUT_SHOW_OS')
|
||||
showCommit = 'y' if os.getenv('INPUT_SHOW_COMMIT') is None else os.getenv('INPUT_SHOW_COMMIT')
|
||||
showLanguage = 'y' if os.getenv('INPUT_SHOW_LANGUAGE') is None else os.getenv('INPUT_SHOW_LANGUAGE')
|
||||
show_loc = 'y' if os.getenv('INPUT_SHOW_LINES_OF_CODE') is None else os.getenv('INPUT_SHOW_LINES_OF_CODE')
|
||||
|
||||
showLanguagePerRepo = os.getenv('INPUT_SHOW_LANGUAGE_PER_REPO')
|
||||
showLocChart = os.getenv('INPUT_SHOW_LOC_CHART')
|
||||
showLanguagePerRepo = 'y' if os.getenv('INPUT_SHOW_LANGUAGE_PER_REPO') is None else 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')
|
||||
show_waka_stats = 'y'
|
||||
# The GraphQL query to get commit data.
|
||||
userInfoQuery = """
|
||||
@@ -93,7 +93,7 @@ def run_v3_api(query):
|
||||
repositoryListQuery = Template("""
|
||||
{
|
||||
user(login: "$username") {
|
||||
repositories(orderBy: {field: CREATED_AT, direction: ASC}, last: 5, affiliations: [OWNER, COLLABORATOR, ORGANIZATION_MEMBER], isFork: false) {
|
||||
repositories(orderBy: {field: CREATED_AT, direction: ASC}, last: 100, affiliations: [OWNER, COLLABORATOR, ORGANIZATION_MEMBER], isFork: false) {
|
||||
totalCount
|
||||
edges {
|
||||
node {
|
||||
@@ -176,7 +176,7 @@ def generate_commit_list(tz):
|
||||
result = run_query(userInfoQuery) # Execute the query
|
||||
username = result["data"]["viewer"]["login"]
|
||||
id = result["data"]["viewer"]["id"]
|
||||
print("user {}".format(username))
|
||||
# print("user {}".format(username))
|
||||
|
||||
result = run_query(createContributedRepoQuery.substitute(username=username))
|
||||
nodes = result["data"]["user"]["repositoriesContributedTo"]["nodes"]
|
||||
@@ -371,6 +371,11 @@ def get_stats():
|
||||
stats = ''
|
||||
repositoryList = run_query(repositoryListQuery.substitute(username=username, id=id))
|
||||
|
||||
|
||||
if show_waka_stats.lower() in ['true', '1', 't', 'y', 'yes']:
|
||||
stats = stats + get_waka_time_stats()
|
||||
|
||||
|
||||
if showLanguagePerRepo.lower() in ['true', '1', 't', 'y', 'yes']:
|
||||
stats = stats + generate_language_per_repo(repositoryList) + '\n\n'
|
||||
|
||||
@@ -381,8 +386,6 @@ def get_stats():
|
||||
stats = stats + ' \n\n'
|
||||
# stats = stats + generate_language_per_repo(repositoryList) + '\n\n'
|
||||
|
||||
if show_waka_stats.lower() in ['true', '1', 't', 'y', 'yes']:
|
||||
stats = stats + get_waka_time_stats()
|
||||
|
||||
return stats
|
||||
|
||||
@@ -408,13 +411,13 @@ if __name__ == '__main__':
|
||||
user_data = run_query(userInfoQuery) # Execute the query
|
||||
username = user_data["data"]["viewer"]["login"]
|
||||
id = user_data["data"]["viewer"]["id"]
|
||||
print("user {} id {}".format(username, id))
|
||||
# print("user {} id {}".format(username, id))
|
||||
repo = g.get_repo(f"{username}/{username}")
|
||||
contents = repo.get_readme()
|
||||
waka_stats = get_stats()
|
||||
rdmd = decode_readme(contents.content)
|
||||
new_readme = generate_new_readme(stats=waka_stats, readme=rdmd)
|
||||
print(new_readme)
|
||||
# print(new_readme)
|
||||
if new_readme != rdmd:
|
||||
repo.update_file(path=contents.path, message='Updated with Dev Metrics',
|
||||
content=new_readme, sha=contents.sha, branch='master')
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import os
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import altair as alt
|
||||
import json
|
||||
|
||||
alt.data_transformers.enable('data_server_proxied')
|
||||
|
||||
|
||||
import os
|
||||
# npm install vega-lite vega-cli canvas
|
||||
|
||||
|
||||
@@ -16,7 +14,7 @@ class BarGraph:
|
||||
|
||||
def build_graph(self):
|
||||
|
||||
with open('colors.json') as f:
|
||||
with open(os.path.join(os.path.dirname(__file__), 'colors.json')) as f:
|
||||
colors = json.load(f)
|
||||
allColorsValues = []
|
||||
|
||||
@@ -37,8 +35,7 @@ class BarGraph:
|
||||
top_languages[language] = 1
|
||||
top_languages[language] += 1
|
||||
|
||||
print("here")
|
||||
print(self.yearly_data)
|
||||
# print(self.yearly_data)
|
||||
|
||||
all_languages = list(top_languages.keys())
|
||||
|
||||
@@ -60,8 +57,7 @@ class BarGraph:
|
||||
language_year.append(language_quarter)
|
||||
languages_all_loc[language] = language_year
|
||||
|
||||
print("here 2")
|
||||
print(languages_all_loc)
|
||||
# print(languages_all_loc)
|
||||
|
||||
language_df = {}
|
||||
|
||||
@@ -80,7 +76,6 @@ class BarGraph:
|
||||
|
||||
df = pd.concat(list(language_df.values()))
|
||||
|
||||
# print(df)
|
||||
|
||||
chart = alt.Chart(df).mark_bar().encode(
|
||||
|
||||
|
||||
39
package-lock.json
generated
39
package-lock.json
generated
@@ -74,16 +74,6 @@
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
|
||||
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="
|
||||
},
|
||||
"canvas": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/canvas/-/canvas-2.6.1.tgz",
|
||||
"integrity": "sha512-S98rKsPcuhfTcYbtF53UIJhcbgIAK533d1kJKMwsMwAIFgfd58MOyxRud3kktlzWiEkFliaJtvyZCBtud/XVEA==",
|
||||
"requires": {
|
||||
"nan": "^2.14.0",
|
||||
"node-pre-gyp": "^0.11.0",
|
||||
"simple-get": "^3.0.3"
|
||||
}
|
||||
},
|
||||
"chownr": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
|
||||
@@ -899,16 +889,6 @@
|
||||
"resolved": "https://registry.npmjs.org/vega-canvas/-/vega-canvas-1.2.2.tgz",
|
||||
"integrity": "sha512-39h8/fZp4kDwSeDGIEoyEiIgtP3mgY3D08InD1Ldm0FntePpSe1tXzC1zcvoLe/+f7Qprl6Jfwux/ksOXvpj2w=="
|
||||
},
|
||||
"vega-cli": {
|
||||
"version": "5.13.0",
|
||||
"resolved": "https://registry.npmjs.org/vega-cli/-/vega-cli-5.13.0.tgz",
|
||||
"integrity": "sha512-5gfN6JmZ4HqNr8gYdu2g+Nkh9MAcsUHJ6Bp1y67vxn9bs8LEWNk1t8vCGlt3BH2CjlyI7jLaF4NRw8bb2IhH8g==",
|
||||
"requires": {
|
||||
"canvas": "^2.6.1",
|
||||
"vega": "5.13.0",
|
||||
"yargs": "15"
|
||||
}
|
||||
},
|
||||
"vega-crossfilter": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/vega-crossfilter/-/vega-crossfilter-4.0.2.tgz",
|
||||
@@ -1019,25 +999,6 @@
|
||||
"vega-util": "^1.13.2"
|
||||
}
|
||||
},
|
||||
"vega-lite": {
|
||||
"version": "4.14.0",
|
||||
"resolved": "https://registry.npmjs.org/vega-lite/-/vega-lite-4.14.0.tgz",
|
||||
"integrity": "sha512-zWwmH3iX/U8xj4RsmpLkLFSVimNh3r/crbOk72MyolsB0v0TB3lRbsf1r5eJCdVPPSVEkE5TXwDYE+ygQ2kgbQ==",
|
||||
"requires": {
|
||||
"@types/clone": "~0.1.30",
|
||||
"@types/fast-json-stable-stringify": "^2.0.0",
|
||||
"array-flat-polyfill": "^1.0.1",
|
||||
"clone": "~2.1.2",
|
||||
"fast-deep-equal": "~3.1.3",
|
||||
"fast-json-stable-stringify": "~2.1.0",
|
||||
"json-stringify-pretty-compact": "~2.0.0",
|
||||
"tslib": "~2.0.0",
|
||||
"vega-event-selector": "~2.0.3",
|
||||
"vega-expression": "~2.6.5",
|
||||
"vega-util": "~1.14.1",
|
||||
"yargs": "~15.4.1"
|
||||
}
|
||||
},
|
||||
"vega-loader": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/vega-loader/-/vega-loader-4.3.0.tgz",
|
||||
|
||||
@@ -2,12 +2,18 @@ altair==4.1.0
|
||||
altair-data-server==0.4.1
|
||||
altair-saver==0.5.0
|
||||
altair-viewer==0.3.0
|
||||
appdirs==1.4.3
|
||||
attrs==19.3.0
|
||||
bcrypt==3.1.7
|
||||
certifi==2020.6.20
|
||||
cffi==1.14.0
|
||||
chardet==3.0.4
|
||||
cryptography==2.9.2
|
||||
cycler==0.10.0
|
||||
Deprecated==1.2.10
|
||||
distlib==0.3.0
|
||||
entrypoints==0.3
|
||||
filelock==3.0.12
|
||||
gitdb==4.0.5
|
||||
GitPython==3.1.7
|
||||
idna==2.10
|
||||
@@ -17,17 +23,30 @@ kiwisolver==1.2.0
|
||||
lizard==1.17.4
|
||||
MarkupSafe==1.1.1
|
||||
matplotlib==3.3.0
|
||||
MouseInfo==0.1.2
|
||||
numpy==1.19.1
|
||||
opencv-python==4.2.0.34
|
||||
pandas==1.0.5
|
||||
paramiko==2.7.1
|
||||
Pillow==7.2.0
|
||||
pipenv==2018.11.26
|
||||
portpicker==1.3.1
|
||||
PyAutoGUI==0.9.48
|
||||
pycparser==2.20
|
||||
PyDriller==1.15.2
|
||||
PyGetWindow==0.0.8
|
||||
PyGithub==1.51
|
||||
PyJWT==1.7.1
|
||||
PyMsgBox==1.0.7
|
||||
PyNaCl==1.3.0
|
||||
pyparsing==2.4.7
|
||||
pyperclip==1.7.0
|
||||
PyRect==0.1.4
|
||||
pyrsistent==0.16.0
|
||||
PyScreeze==0.1.25
|
||||
python-dateutil==2.8.1
|
||||
python-dotenv==0.14.0
|
||||
PyTweening==1.0.3
|
||||
pytz==2020.1
|
||||
requests==2.24.0
|
||||
selenium==3.141.0
|
||||
@@ -36,4 +55,8 @@ smmap==3.0.4
|
||||
toolz==0.10.0
|
||||
tornado==6.0.4
|
||||
urllib3==1.25.9
|
||||
virtualenv==20.0.18
|
||||
virtualenv-clone==0.5.4
|
||||
wrapt==1.12.1
|
||||
xlrd==1.2.0
|
||||
XlsxWriter==1.2.8
|
||||
|
||||
Reference in New Issue
Block a user