Formatting

This commit is contained in:
Connor Johnstone
2026-03-18 15:37:10 -04:00
parent 1f36374394
commit 93392db27c
8 changed files with 250 additions and 161 deletions

View File

@@ -1,4 +1,4 @@
use actix_web::{web, HttpResponse};
use actix_web::{HttpResponse, web};
use serde::{Deserialize, Serialize};
use shanty_db::entities::wanted_item::WantedStatus;
@@ -15,7 +15,9 @@ pub struct PaginationParams {
#[serde(default)]
offset: u64,
}
fn default_limit() -> u64 { 50 }
fn default_limit() -> u64 {
50
}
#[derive(Deserialize)]
pub struct AddAlbumRequest {
@@ -40,10 +42,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
.route(web::get().to(list_albums))
.route(web::post().to(add_album)),
)
.service(
web::resource("/albums/{mbid}")
.route(web::get().to(get_album)),
);
.service(web::resource("/albums/{mbid}").route(web::get().to(get_album)));
}
async fn list_albums(
@@ -69,7 +68,8 @@ async fn get_album(
Err(_) => {
// Probably a release-group MBID. Browse releases for this group.
let release_mbid = resolve_release_from_group(&state, &mbid).await?;
state.mb_client
state
.mb_client
.get_release_tracks(&release_mbid)
.await
.map_err(|e| ApiError::Internal(format!("MusicBrainz error: {e}")))?
@@ -112,7 +112,7 @@ async fn get_album(
/// Given a release-group MBID, find the first release MBID via the MB API.
async fn resolve_release_from_group(
state: &web::Data<AppState>,
_state: &web::Data<AppState>,
release_group_mbid: &str,
) -> Result<String, ApiError> {
// Use the MB client's get_json (it's private, so we go through search)
@@ -152,7 +152,11 @@ async fn resolve_release_from_group(
.and_then(|r| r.get("id"))
.and_then(|id| id.as_str())
.map(String::from)
.ok_or_else(|| ApiError::NotFound(format!("no releases found for release group {release_group_mbid}")))
.ok_or_else(|| {
ApiError::NotFound(format!(
"no releases found for release group {release_group_mbid}"
))
})
}
async fn add_album(