refactor(adapters): update FeedEntry construction to use EngagementStats + ViewerContext
This commit is contained in:
@@ -29,11 +29,11 @@ pub fn to_thought_response(e: &domain::models::feed::FeedEntry) -> ThoughtRespon
|
||||
visibility: e.thought.visibility.as_str().to_string(),
|
||||
content_warning: e.thought.content_warning.clone(),
|
||||
sensitive: e.thought.sensitive,
|
||||
like_count: e.like_count,
|
||||
boost_count: e.boost_count,
|
||||
reply_count: e.reply_count,
|
||||
liked_by_viewer: e.liked_by_viewer,
|
||||
boosted_by_viewer: e.boosted_by_viewer,
|
||||
like_count: e.stats.like_count,
|
||||
boost_count: e.stats.boost_count,
|
||||
reply_count: e.stats.reply_count,
|
||||
liked_by_viewer: e.viewer.as_ref().map(|v| v.liked).unwrap_or(false),
|
||||
boosted_by_viewer: e.viewer.as_ref().map(|v| v.boosted).unwrap_or(false),
|
||||
created_at: e.thought.created_at,
|
||||
updated_at: e.thought.updated_at,
|
||||
}
|
||||
@@ -103,15 +103,8 @@ pub async fn search_handler(
|
||||
let query = q.q.trim().to_string();
|
||||
|
||||
let (thoughts_result, users_result) = tokio::join!(
|
||||
s.search.search_thoughts(
|
||||
&query,
|
||||
&page,
|
||||
viewer.as_ref()
|
||||
),
|
||||
s.search.search_users(
|
||||
&query,
|
||||
&page
|
||||
),
|
||||
s.search.search_thoughts(&query, &page, viewer.as_ref()),
|
||||
s.search.search_users(&query, &page),
|
||||
);
|
||||
|
||||
let thoughts = thoughts_result?
|
||||
@@ -122,9 +115,9 @@ pub async fn search_handler(
|
||||
"id": e.thought.id.as_uuid(),
|
||||
"content": e.thought.content.as_str(),
|
||||
"author": to_user_response(&e.author),
|
||||
"like_count": e.like_count,
|
||||
"boost_count": e.boost_count,
|
||||
"reply_count": e.reply_count,
|
||||
"like_count": e.stats.like_count,
|
||||
"boost_count": e.stats.boost_count,
|
||||
"reply_count": e.stats.reply_count,
|
||||
"created_at": e.thought.created_at,
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user