diff --git a/assets/banner.txt b/assets/banner.txt index d256f4c..531f695 100644 --- a/assets/banner.txt +++ b/assets/banner.txt @@ -1,6 +1,9 @@ - ______ _ _______ __ __ __ - /_ __/_ __(_) ____(_) /_/ /_ __ __/ /_ - / / / / / / / / __/ / __/ __ \/ / / / __ \ - / / / /_/ / / /_/ / / /_/ / / / /_/ / /_/ / -/_/ \__,_/_/\____/_/\__/_/ /_/\__,_/_.___/ \ No newline at end of file + $$$$$$\ $$\ $$\ $$\ +$$ __$$\ \__| $$ | \__| +$$ / \__|$$\ $$$$$$\ $$\ $$\ $$\ +$$ |$$$$\ $$ |\_$$ _| $$ | $$ |$$ | +$$ |\_$$ |$$ | $$ | $$ | $$ |$$ | +$$ | $$ |$$ | $$ |$$\ $$ | $$ |$$ | +\$$$$$$ |$$ | \$$$$ |\$$$$$$ |$$ | + \______/ \__| \____/ \______/ \__| \ No newline at end of file diff --git a/screens/repo_view_screen.py b/screens/repo_view_screen.py index ba143dd..b420330 100644 --- a/screens/repo_view_screen.py +++ b/screens/repo_view_screen.py @@ -2,6 +2,7 @@ from textual.screen import Screen from textual.app import ComposeResult from textual.widgets import Input, Select, LoadingIndicator, Static, DataTable, ContentSwitcher, Tabs, Tab, Button from textual.containers import VerticalGroup, Vertical, HorizontalGroup, Right +from textual import work from widgets import Navbar @@ -83,8 +84,9 @@ class RepoViewScreen(Screen): return "\uf15b" else: return "\ue5ff" - - async def on_mount(self): + + @work(thread=True, exclusive=True) + def on_mount(self): files: DataTable = self.query_one("#files") loading = self.query_one(LoadingIndicator) @@ -123,18 +125,31 @@ 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_page_number = 1 + page_size = 50 commit_data = {} - for commit in commits: - commit_data[commit["sha"]] = commit + + while True: + commits = requests.get( + self.app.GITEA_HOST + f"api/v1/repos/{self.owner_name}/{self.repo_name}/commits", + params={ + #"path": ".", + "verification": False, + "files": False, + "page": commit_page_number, + "limit": page_size + } + ).json() + + + commit_data.update({commit["sha"]: commit for commit in commits}) + + if len(commits) == page_size: # we reached end of the page + commit_page_number += 1 + else: + break for file in files_response.json(): - commit = commit_data[file["last_commit_sha"]] commit_created_at = datetime.fromisoformat(commit["created"]).replace(tzinfo=None) @@ -142,7 +157,7 @@ class RepoViewScreen(Screen): rows.append(( f"[cyan]{self.get_icon_from_name_and_type(file["name"], file["type"] != "file")}[/] {file["name"]}", f"[d]{commit["commit"]["message"]}", - f"Updated {time_delta(datetime.now() - commit_created_at)} ago" + f"[d]Updated {time_delta(datetime.now() - commit_created_at)} ago" )) files.add_rows(rows) diff --git a/screens/search_screen.py b/screens/search_screen.py index 3c08aa4..7ed16b4 100644 --- a/screens/search_screen.py +++ b/screens/search_screen.py @@ -1,9 +1,10 @@ -from widgets import Navbar from textual.screen import Screen from textual.widgets import Input, Select, LoadingIndicator, Static from textual.containers import HorizontalGroup, ScrollableContainer from textual.app import ComposeResult +from textual import work +from widgets import Navbar from screens.repo_view_screen import RepoViewScreen from human_readable import time_delta @@ -66,7 +67,8 @@ class SearchScreen(Screen): def action_view_repo(self, author: str, repo_name: str): self.app.switch_screen(RepoViewScreen(author, repo_name)) - def action_search_query(self): + @work(exclusive=True) + async def action_search_query(self): query_input = self.query_one("#query") loading = self.query_one(LoadingIndicator) results = self.query_one(ScrollableContainer) @@ -92,7 +94,6 @@ class SearchScreen(Screen): # display results results.remove_children(SearchResult) to_mount = [] - print(response.json()) for result in response.json()["data"]: to_mount.append(SearchResult(result)) results.mount_all(to_mount)