mirror of
https://github.com/modrinth/code.git
synced 2026-08-27 01:54:47 +00:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user