feat: user search (#6302)

* feat: user search

* refactor: use sqlx macro

* refactor: better name for escaped query

* style: cleanup unused import

* chore: update sqlx query cache

* fix: tests

---------

Co-authored-by: sychic <47618543+Sychic@users.noreply.github.com>
This commit is contained in:
Calum H.
2026-06-03 19:38:24 +00:00
committed by GitHub
co-authored by sychic
parent d907083d83
commit 58ad58f958
6 changed files with 237 additions and 2 deletions
+20 -1
View File
@@ -73,6 +73,13 @@ pub struct User {
pub github_id: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
pub struct SearchUser {
pub id: UserId,
pub username: String,
pub avatar_url: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
pub struct UserCampaigns {
pub pride_26: Option<Pride26CampaignDonation>,
@@ -87,7 +94,9 @@ pub struct UserPayoutData {
pub balance: Decimal,
}
use crate::database::models::user_item::{DBUser, Pride26CampaignDonation};
use crate::database::models::user_item::{
DBSearchUser, DBUser, Pride26CampaignDonation,
};
impl From<DBUser> for User {
fn from(data: DBUser) -> Self {
@@ -116,6 +125,16 @@ impl From<DBUser> for User {
}
}
impl From<DBSearchUser> for SearchUser {
fn from(data: DBSearchUser) -> Self {
Self {
id: data.id.into(),
username: data.username,
avatar_url: data.avatar_url,
}
}
}
impl User {
pub fn from_full(db_user: DBUser) -> Self {
let mut auth_providers = Vec::new();