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:
@@ -123,14 +123,19 @@ class RepoViewScreen(Screen):
|
||||
|
||||
|
||||
rows = []
|
||||
commits = requests.get(
|
||||
self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/commits",
|
||||
params={
|
||||
"path": "."
|
||||
}
|
||||
).json()
|
||||
commit_data = {}
|
||||
for commit in commits:
|
||||
commit_data[commit["sha"]] = commit
|
||||
|
||||
for file in files_response.json():
|
||||
|
||||
commit_sha = 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 = commit_data[file["last_commit_sha"]]
|
||||
|
||||
commit_created_at = datetime.fromisoformat(commit["created"]).replace(tzinfo=None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user