Spaces:
Sleeping
Sleeping
| use crate::interfaces::http::api::AppState; | |
| use crate::interfaces::http::routes::RequireAuth; | |
| use axum::{extract::State, http::StatusCode, Json}; | |
| use crate::domain::models::analytics::*; | |
| pub async fn get_merchant_analytics( | |
| State(state): State<AppState>, | |
| RequireAuth(merchant_id): RequireAuth, | |
| ) -> Result<Json<AnalyticsResponse>, StatusCode> { | |
| state | |
| .merchant_service | |
| .get_analytics(&merchant_id) | |
| .await | |
| .map(Json) | |
| .map_err(|e| { | |
| tracing::error!( | |
| "Failed to fetch merchant analytics for {}: {:?}", | |
| merchant_id, | |
| e | |
| ); | |
| StatusCode::INTERNAL_SERVER_ERROR | |
| }) | |
| } | |