Fixed some warnings and improved the code quality some more
This commit is contained in:
@@ -43,13 +43,12 @@ pub async fn get_demo_from_upload(
|
||||
pub mod api;
|
||||
pub mod steam_api;
|
||||
|
||||
#[tracing::instrument(skip(upload_folder, base_analysis_tx))]
|
||||
pub async fn run_api<UP>(
|
||||
upload_folder: UP,
|
||||
#[tracing::instrument(skip(upload_folder, base_analysis_tx, steam_api_key))]
|
||||
pub async fn run_api(
|
||||
upload_folder: impl Into<std::path::PathBuf>,
|
||||
base_analysis_tx: tokio::sync::mpsc::UnboundedSender<analysis::AnalysisInput>,
|
||||
) where
|
||||
UP: Into<std::path::PathBuf>,
|
||||
{
|
||||
steam_api_key: impl Into<String>,
|
||||
) {
|
||||
let upload_folder: std::path::PathBuf = upload_folder.into();
|
||||
|
||||
let session_store = crate::diesel_sessionstore::DieselStore::new();
|
||||
@@ -64,7 +63,18 @@ pub async fn run_api<UP>(
|
||||
}
|
||||
|
||||
let router = axum::Router::new()
|
||||
.nest("/api/", crate::api::router(base_analysis_tx))
|
||||
.nest(
|
||||
"/api/",
|
||||
crate::api::router(
|
||||
base_analysis_tx,
|
||||
crate::api::RouterConfig {
|
||||
steam_api_key: steam_api_key.into(),
|
||||
steam_callback_base_url: "http://192.168.0.156:3000".into(),
|
||||
steam_callback_path: "/api/steam/callback".into(),
|
||||
upload_dir: upload_folder.clone(),
|
||||
},
|
||||
),
|
||||
)
|
||||
.layer(session_layer)
|
||||
.nest_service(
|
||||
"/",
|
||||
@@ -75,7 +85,7 @@ pub async fn run_api<UP>(
|
||||
axum::serve(listener, router).await.unwrap();
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[tracing::instrument(skip(base_analysis_rx))]
|
||||
pub async fn run_analysis(
|
||||
mut base_analysis_rx: tokio::sync::mpsc::UnboundedReceiver<analysis::AnalysisInput>,
|
||||
) {
|
||||
@@ -89,7 +99,7 @@ pub async fn run_analysis(
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
dbg!(&result);
|
||||
tracing::debug!("Analysis-Result: {:?}", result);
|
||||
|
||||
let mut db_con = crate::db_connection().await;
|
||||
|
||||
@@ -109,11 +119,12 @@ pub async fn run_analysis(
|
||||
db_con
|
||||
.transaction::<'_, '_, '_, _, diesel::result::Error, _>(|conn| {
|
||||
Box::pin(async move {
|
||||
store_info_query.execute(conn).await.map(|e| ())?;
|
||||
update_process_info.execute(conn).await.map(|e| ())?;
|
||||
store_info_query.execute(conn).await?;
|
||||
update_process_info.execute(conn).await?;
|
||||
Ok(())
|
||||
})
|
||||
})
|
||||
.await;
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user