MCPcopy Create free account
hub / github.com/acking-you/static_flow / fetch_article_comment_stats

Function fetch_article_comment_stats

crates/frontend/src/api.rs:3423–3453  ·  view source on GitHub ↗
(article_id: &str)

Source from the content-addressed store, hash-verified

3421}
3422
3423pub async fn fetch_article_comment_stats(article_id: &str) -> Result<CommentStatsResponse, String> {
3424 if article_id.trim().is_empty() {
3425 return Err("article_id is empty".to_string());
3426 }
3427
3428 #[cfg(feature = "mock")]
3429 {
3430 Ok(CommentStatsResponse {
3431 article_id: article_id.to_string(),
3432 total: 0,
3433 })
3434 }
3435
3436 #[cfg(not(feature = "mock"))]
3437 {
3438 let url =
3439 format!("{}/comments/stats?article_id={}", API_BASE, urlencoding::encode(article_id),);
3440 let response = api_get(&url)
3441 .send()
3442 .await
3443 .map_err(|e| format!("Network error: {:?}", e))?;
3444 if !response.ok() {
3445 return Err(format!("HTTP error: {}", response.status()));
3446 }
3447
3448 response
3449 .json()
3450 .await
3451 .map_err(|e| format!("Parse error: {:?}", e))
3452 }
3453}
3454
3455pub async fn fetch_admin_view_analytics_config() -> Result<ViewAnalyticsConfig, String> {
3456 #[cfg(feature = "mock")]

Callers 1

article_detail_pageFunction · 0.85

Calls 4

api_getFunction · 0.85
trimMethod · 0.80
okMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected