You've already forked AstralRinth
forked from didirus/AstralRinth
Initial work on payouts (badges, perms, splits) (#440)
* Initial work on payouts (badges, perms, splits) * Fix clippy error, bitflag consistency
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use super::ids::{ProjectId, UserId};
|
||||
use crate::models::users::Badges;
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
pub struct User {
|
||||
@@ -11,6 +12,7 @@ pub struct User {
|
||||
pub bio: Option<String>,
|
||||
pub created: DateTime<Utc>,
|
||||
pub role: String,
|
||||
pub badges: Badges,
|
||||
}
|
||||
|
||||
impl User {
|
||||
@@ -54,7 +56,7 @@ impl User {
|
||||
"
|
||||
SELECT u.github_id, u.name, u.email,
|
||||
u.avatar_url, u.username, u.bio,
|
||||
u.created, u.role
|
||||
u.created, u.role, u.badges
|
||||
FROM users u
|
||||
WHERE u.id = $1
|
||||
",
|
||||
@@ -74,6 +76,8 @@ impl User {
|
||||
bio: row.bio,
|
||||
created: row.created,
|
||||
role: row.role,
|
||||
badges: Badges::from_bits(row.badges as u64)
|
||||
.unwrap_or_default(),
|
||||
}))
|
||||
} else {
|
||||
Ok(None)
|
||||
@@ -91,7 +95,7 @@ impl User {
|
||||
"
|
||||
SELECT u.id, u.name, u.email,
|
||||
u.avatar_url, u.username, u.bio,
|
||||
u.created, u.role
|
||||
u.created, u.role, u.badges
|
||||
FROM users u
|
||||
WHERE u.github_id = $1
|
||||
",
|
||||
@@ -111,6 +115,8 @@ impl User {
|
||||
bio: row.bio,
|
||||
created: row.created,
|
||||
role: row.role,
|
||||
badges: Badges::from_bits(row.badges as u64)
|
||||
.unwrap_or_default(),
|
||||
}))
|
||||
} else {
|
||||
Ok(None)
|
||||
@@ -128,7 +134,7 @@ impl User {
|
||||
"
|
||||
SELECT u.id, u.github_id, u.name, u.email,
|
||||
u.avatar_url, u.username, u.bio,
|
||||
u.created, u.role
|
||||
u.created, u.role, u.badges
|
||||
FROM users u
|
||||
WHERE LOWER(u.username) = LOWER($1)
|
||||
",
|
||||
@@ -148,6 +154,8 @@ impl User {
|
||||
bio: row.bio,
|
||||
created: row.created,
|
||||
role: row.role,
|
||||
badges: Badges::from_bits(row.badges as u64)
|
||||
.unwrap_or_default(),
|
||||
}))
|
||||
} else {
|
||||
Ok(None)
|
||||
@@ -169,7 +177,8 @@ impl User {
|
||||
"
|
||||
SELECT u.id, u.github_id, u.name, u.email,
|
||||
u.avatar_url, u.username, u.bio,
|
||||
u.created, u.role FROM users u
|
||||
u.created, u.role, u.badges
|
||||
FROM users u
|
||||
WHERE u.id = ANY($1)
|
||||
",
|
||||
&user_ids_parsed
|
||||
@@ -186,6 +195,7 @@ impl User {
|
||||
bio: u.bio,
|
||||
created: u.created,
|
||||
role: u.role,
|
||||
badges: Badges::from_bits(u.badges as u64).unwrap_or_default(),
|
||||
}))
|
||||
})
|
||||
.try_collect::<Vec<User>>()
|
||||
|
||||
Reference in New Issue
Block a user