From 517107f718d3474128028f1e72fce1a62150bd5d Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 16 Mar 2021 13:51:34 +0100 Subject: chore: add doc for create repo endpoint --- src/repository/routes.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/repository') diff --git a/src/repository/routes.rs b/src/repository/routes.rs index a0f4db5..abf77b6 100644 --- a/src/repository/routes.rs +++ b/src/repository/routes.rs @@ -80,6 +80,7 @@ async fn delete_repo( .map_err(|e| e) } +/// Endpoint used for create new repository async fn create_repo( req: HttpRequest, payload: web::Json, -- cgit v1.2.3-18-g5258 From 2689fe31f9f86ba190faea99635e62f624e3e02d Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 16 Mar 2021 13:53:13 +0100 Subject: chore: better use of query_opt --- src/repository/models.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/repository') diff --git a/src/repository/models.rs b/src/repository/models.rs index 1cbf3bb..e3d8456 100644 --- a/src/repository/models.rs +++ b/src/repository/models.rs @@ -180,12 +180,9 @@ impl Repository { }; let repo = client - .query(&statement, &[&uuid, &repo_name, &user_ip]) + .query_opt(&statement, &[&uuid, &repo_name, &user_ip]) .await? - .iter() - .map(|row| Repository::from_row_ref(row).unwrap()) - .collect::>() - .pop(); + .map(|row| Repository::from_row_ref(&row).unwrap()); match repo { Some(repo) => Ok(repo), -- cgit v1.2.3-18-g5258