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

Function fetch_article_comments

crates/frontend/src/api.rs:3382–3421  ·  view source on GitHub ↗
(
    article_id: &str,
    limit: Option<usize>,
)

Source from the content-addressed store, hash-verified

3380}
3381
3382pub async fn fetch_article_comments(
3383 article_id: &str,
3384 limit: Option<usize>,
3385) -> Result<CommentListResponse, String> {
3386 if article_id.trim().is_empty() {
3387 return Err("article_id is empty".to_string());
3388 }
3389
3390 #[cfg(feature = "mock")]
3391 {
3392 let _ = limit;
3393 Ok(CommentListResponse {
3394 comments: vec![],
3395 total: 0,
3396 article_id: article_id.to_string(),
3397 })
3398 }
3399
3400 #[cfg(not(feature = "mock"))]
3401 {
3402 let mut url =
3403 format!("{}/comments/list?article_id={}", API_BASE, urlencoding::encode(article_id),);
3404 if let Some(limit) = limit {
3405 url.push_str(&format!("&limit={limit}"));
3406 }
3407
3408 let response = api_get(&url)
3409 .send()
3410 .await
3411 .map_err(|e| format!("Network error: {:?}", e))?;
3412 if !response.ok() {
3413 return Err(format!("HTTP error: {}", response.status()));
3414 }
3415
3416 response
3417 .json()
3418 .await
3419 .map_err(|e| format!("Parse error: {:?}", e))
3420 }
3421}
3422
3423pub async fn fetch_article_comment_stats(article_id: &str) -> Result<CommentStatsResponse, String> {
3424 if article_id.trim().is_empty() {

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