feat: GET /users (search/list) and GET /users/count

This commit is contained in:
2026-05-14 15:34:37 +02:00
parent a2cc4fba21
commit eb7dbb0aee
4 changed files with 62 additions and 1 deletions

View File

@@ -47,6 +47,7 @@ pub trait UserRepository: Send + Sync {
async fn save(&self, user: &User) -> Result<(), DomainError>;
async fn update_profile(&self, user_id: &UserId, display_name: Option<String>, bio: Option<String>, avatar_url: Option<String>, header_url: Option<String>, custom_css: Option<String>) -> Result<(), DomainError>;
async fn list_with_stats(&self) -> Result<Vec<UserSummary>, DomainError>;
async fn count(&self) -> Result<i64, DomainError>;
}
#[async_trait]
@@ -100,6 +101,8 @@ pub trait TagRepository: Send + Sync {
async fn detach_from_thought(&self, thought_id: &ThoughtId) -> Result<(), DomainError>;
async fn list_for_thought(&self, thought_id: &ThoughtId) -> Result<Vec<Tag>, DomainError>;
async fn list_thoughts_by_tag(&self, tag_name: &str, page: &PageParams) -> Result<Paginated<Thought>, DomainError>;
/// Returns (tag_name, thought_count) pairs ordered by usage, most popular first.
async fn popular_tags(&self, limit: usize) -> Result<Vec<(String, i64)>, DomainError>;
}
#[async_trait]

View File

@@ -62,6 +62,9 @@ pub struct TestStore {
Ok(())
}
async fn list_with_stats(&self) -> Result<Vec<UserSummary>, DomainError> { Ok(vec![]) }
async fn count(&self) -> Result<i64, DomainError> {
Ok(self.users.lock().unwrap().iter().filter(|u| u.local).count() as i64)
}
}
#[async_trait] impl ThoughtRepository for TestStore {
@@ -211,6 +214,9 @@ pub struct TestStore {
async fn list_thoughts_by_tag(&self, _name: &str, _p: &PageParams) -> Result<Paginated<Thought>, DomainError> {
Ok(Paginated { items: vec![], total: 0, page: 1, per_page: 20 })
}
async fn popular_tags(&self, _limit: usize) -> Result<Vec<(String, i64)>, DomainError> {
Ok(vec![])
}
}
#[async_trait] impl ApiKeyRepository for TestStore {