optimized getting commit data a TON lmao

we send only one request instead of a request for every file plus an extra request
This commit is contained in:
2026-02-05 16:16:32 +11:00
parent 1721c65ccd
commit 162caa98b3

View File

@@ -123,14 +123,19 @@ class RepoViewScreen(Screen):
rows = [] rows = []
commits = requests.get(
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/commits",
params={
"path": "."
}
).json()
commit_data = {} commit_data = {}
for commit in commits:
commit_data[commit["sha"]] = commit
for file in files_response.json(): for file in files_response.json():
commit_sha = file["last_commit_sha"] commit = commit_data[file["last_commit_sha"]]
commit = commit_data[commit_sha] if commit_sha in commit_data else requests.get(
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/git/commits/{file["last_commit_sha"]}"
).json()
commit_data[commit_sha] = commit
commit_created_at = datetime.fromisoformat(commit["created"]).replace(tzinfo=None) commit_created_at = datetime.fromisoformat(commit["created"]).replace(tzinfo=None)