refactor: labrinth ApiError and error reporting (#6981)

* refactor: labrinth `ApiError` and error reporting

* fix clippy

* fix ci
This commit is contained in:
aecsocket
2026-08-07 15:47:54 +00:00
committed by GitHub
parent d344cbcb7a
commit 3fa6905006
102 changed files with 6449 additions and 3791 deletions
+21 -5
View File
@@ -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`")
}