generated files moved to 'assets' dir, graph drawing fixed

This commit is contained in:
pseusys
2023-02-17 00:38:26 +01:00
parent c9905b51b1
commit 52318d9afe
5 changed files with 79 additions and 82 deletions

View File

@@ -5,10 +5,11 @@ from github import Github, InputGitAuthor, AuthenticatedUser
import datetime
from download_manager import DownloadManager
from make_bar_graph import build_graph
from graph_drawer import create_loc_graph
class LinesOfCode:
GRAPH_PATH = "assets/bar_graph.png"
def __init__(self, user: AuthenticatedUser, ghtoken, repositoryData, ignored_repos):
self.g = Github(ghtoken)
@@ -28,7 +29,7 @@ class LinesOfCode:
return yearly_data
async def plotLoc(self, yearly_data):
await build_graph(yearly_data)
await create_loc_graph(yearly_data, LinesOfCode.GRAPH_PATH)
self.pushChart()
def getQuarter(self, timeStamp):
@@ -67,10 +68,10 @@ class LinesOfCode:
def pushChart(self):
repo = self.g.get_repo(f"{self.user.login}/{self.user.login}")
committer = InputGitAuthor('readme-bot', '41898282+github-actions[bot]@users.noreply.github.com')
with open('bar_graph.png', 'rb') as input_file:
with open(LinesOfCode.GRAPH_PATH, 'rb') as input_file:
data = input_file.read()
try:
contents = repo.get_contents("charts/bar_graph.png")
contents = repo.get_contents(LinesOfCode.GRAPH_PATH)
repo.update_file(contents.path, "Charts Updated", data, contents.sha, committer=committer)
except Exception as e:
repo.create_file("charts/bar_graph.png", "Charts Added", data, committer=committer)
repo.create_file(LinesOfCode.GRAPH_PATH, "Charts Added", data, committer=committer)