From 8caed1f6b18ef2d01af06a1d42d620c90cdaf0b0 Mon Sep 17 00:00:00 2001 From: Silen Locatelli <88315530+SilenLoc@users.noreply.github.com> Date: Tue, 18 Jun 2024 12:58:02 +0200 Subject: [PATCH] feat: all deps have a id --- README.md | 2 +- src-tauri/src/github/mod.rs | 1 - src-tauri/src/github/remote.rs | 9 ++++++--- src/FlatDep.tsx | 6 ++++++ src/Represenation.ts | 10 ++-------- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 93ffc50..7c86d9c 100644 --- a/README.md +++ b/README.md @@ -14,4 +14,4 @@ Using: - tauri - react - material ui -- github api +- github api \ No newline at end of file diff --git a/src-tauri/src/github/mod.rs b/src-tauri/src/github/mod.rs index 6e8fbd2..5dfd333 100644 --- a/src-tauri/src/github/mod.rs +++ b/src-tauri/src/github/mod.rs @@ -10,7 +10,6 @@ pub async fn get_deps_from_github( println!("getting repos for : {:?}", org); let result = github.get_repos(org, token).await?; let mut deps: Vec = vec![]; - println!("repos: {:?}", result); for repo in result { let graph = github.get_graph(org, &repo.name, token).await; diff --git a/src-tauri/src/github/remote.rs b/src-tauri/src/github/remote.rs index 394153f..0ef50a2 100644 --- a/src-tauri/src/github/remote.rs +++ b/src-tauri/src/github/remote.rs @@ -30,7 +30,7 @@ impl Github { }; let mut headers = header::HeaderMap::new(); - headers.insert("Accept", "application/vnd.github+json".parse().unwrap()); + headers.insert("Accept", "application/json".parse().unwrap()); headers.insert("X-GitHub-Api-Version", "2022-11-28".parse().unwrap()); headers.insert("User-Agent", "Dreamy-App".parse().unwrap()); @@ -42,12 +42,15 @@ impl Github { let res = self .client .get(url) - .query(&[("per_page", "100"), ("page", "100")]) + .query(&[("per_page", "100"), ("page", "1")]) .headers(headers) .send() .await .map_err(|f| f.to_string()); - let json: Vec = res?.json().await.map_err(|f| f.to_string())?; + + let as_text = res?.text().await.map_err(|f| f.to_string())?; + + let json: Vec = serde_json::from_str(&as_text).map_err(|f| f.to_string())?; Ok(json) } diff --git a/src/FlatDep.tsx b/src/FlatDep.tsx index 175c26f..e8e8d29 100644 --- a/src/FlatDep.tsx +++ b/src/FlatDep.tsx @@ -35,6 +35,12 @@ function FlatDepComp(props: { } const columns: GridColDef[] = [ + { + field: "uuid", + headerName: "Id", + width: 100, + editable: false, + }, { field: "org", headerName: "Organization", diff --git a/src/Represenation.ts b/src/Represenation.ts index 63265c9..19276cd 100644 --- a/src/Represenation.ts +++ b/src/Represenation.ts @@ -1,4 +1,5 @@ export interface FlatDep { + uuid: string; org: string; repo: string; packageType: string; @@ -7,12 +8,5 @@ export interface FlatDep { } export function flatDepKey(fd: FlatDep) { - return ( - fd.org + - fd.currentValue + - fd.depName + - fd.repo + - fd.packageType + - Math.random() - ); + return fd.uuid; }