mirror of
https://github.com/modrinth/code.git
synced 2026-08-28 10:34:53 +00:00
refactor: labrinth ApiError and error reporting (#6981)
* refactor: labrinth `ApiError` and error reporting * fix clippy * fix ci
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::util::error::Context as _;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{models::ids::ProjectId, routes::ApiError};
|
||||
@@ -47,7 +48,10 @@ pub async fn fetch_playtimes(
|
||||
.bind(end_date.timestamp())
|
||||
.bind(projects.iter().map(|x| x.0).collect::<Vec<_>>());
|
||||
|
||||
Ok(query.fetch_all().await?)
|
||||
query
|
||||
.fetch_all()
|
||||
.await
|
||||
.wrap_internal_err("querying database for `fetch_playtimes`")
|
||||
}
|
||||
|
||||
// Fetches views as a Vec of ReturnViews
|
||||
@@ -77,7 +81,10 @@ pub async fn fetch_views(
|
||||
.bind(end_date.timestamp())
|
||||
.bind(projects.iter().map(|x| x.0).collect::<Vec<_>>());
|
||||
|
||||
Ok(query.fetch_all().await?)
|
||||
query
|
||||
.fetch_all()
|
||||
.await
|
||||
.wrap_internal_err("querying database for `fetch_views`")
|
||||
}
|
||||
|
||||
// Fetches downloads as a Vec of ReturnDownloads
|
||||
@@ -106,7 +113,10 @@ pub async fn fetch_downloads(
|
||||
.bind(end_date.timestamp())
|
||||
.bind(projects.iter().map(|x| x.0).collect::<Vec<_>>());
|
||||
|
||||
Ok(query.fetch_all().await?)
|
||||
query
|
||||
.fetch_all()
|
||||
.await
|
||||
.wrap_internal_err("querying database for `fetch_downloads`")
|
||||
}
|
||||
|
||||
pub async fn fetch_countries_downloads(
|
||||
@@ -133,7 +143,10 @@ pub async fn fetch_countries_downloads(
|
||||
.bind(end_date.timestamp())
|
||||
.bind(projects.iter().map(|x| x.0).collect::<Vec<_>>());
|
||||
|
||||
Ok(query.fetch_all().await?)
|
||||
query
|
||||
.fetch_all()
|
||||
.await
|
||||
.wrap_internal_err("querying database for `fetch_countries_downloads`")
|
||||
}
|
||||
|
||||
pub async fn fetch_countries_views(
|
||||
@@ -160,5 +173,8 @@ pub async fn fetch_countries_views(
|
||||
.bind(end_date.timestamp())
|
||||
.bind(projects.iter().map(|x| x.0).collect::<Vec<_>>());
|
||||
|
||||
Ok(query.fetch_all().await?)
|
||||
query
|
||||
.fetch_all()
|
||||
.await
|
||||
.wrap_internal_err("querying database for `fetch_countries_views`")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user