You've already forked AstralRinth
forked from didirus/AstralRinth
Labrinth ID cleanup (#3681)
* Put all ID types in the labrinth::models::ids, and reduce code duplication with them * Rewrite labrinth::database::models::ids and rename most DB interface ID structs to be prefixed with DB * Run sqlx prepare --------- Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com>
This commit is contained in:
@@ -3,12 +3,12 @@ use chrono::{DateTime, Utc};
|
||||
use rust_decimal::Decimal;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{DatabaseError, PayoutId, UserId};
|
||||
use super::{DBPayoutId, DBUserId, DatabaseError};
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone, Debug)]
|
||||
pub struct Payout {
|
||||
pub id: PayoutId,
|
||||
pub user_id: UserId,
|
||||
pub id: DBPayoutId,
|
||||
pub user_id: DBUserId,
|
||||
pub created: DateTime<Utc>,
|
||||
pub status: PayoutStatus,
|
||||
pub amount: Decimal,
|
||||
@@ -49,7 +49,7 @@ impl Payout {
|
||||
}
|
||||
|
||||
pub async fn get<'a, 'b, E>(
|
||||
id: PayoutId,
|
||||
id: DBPayoutId,
|
||||
executor: E,
|
||||
) -> Result<Option<Payout>, DatabaseError>
|
||||
where
|
||||
@@ -61,7 +61,7 @@ impl Payout {
|
||||
}
|
||||
|
||||
pub async fn get_many<'a, E>(
|
||||
payout_ids: &[PayoutId],
|
||||
payout_ids: &[DBPayoutId],
|
||||
exec: E,
|
||||
) -> Result<Vec<Payout>, DatabaseError>
|
||||
where
|
||||
@@ -79,8 +79,8 @@ impl Payout {
|
||||
)
|
||||
.fetch(exec)
|
||||
.map_ok(|r| Payout {
|
||||
id: PayoutId(r.id),
|
||||
user_id: UserId(r.user_id),
|
||||
id: DBPayoutId(r.id),
|
||||
user_id: DBUserId(r.user_id),
|
||||
created: r.created,
|
||||
status: PayoutStatus::from_string(&r.status),
|
||||
amount: r.amount,
|
||||
@@ -96,9 +96,9 @@ impl Payout {
|
||||
}
|
||||
|
||||
pub async fn get_all_for_user(
|
||||
user_id: UserId,
|
||||
user_id: DBUserId,
|
||||
exec: impl sqlx::Executor<'_, Database = sqlx::Postgres>,
|
||||
) -> Result<Vec<PayoutId>, DatabaseError> {
|
||||
) -> Result<Vec<DBPayoutId>, DatabaseError> {
|
||||
let results = sqlx::query!(
|
||||
"
|
||||
SELECT id
|
||||
@@ -112,7 +112,7 @@ impl Payout {
|
||||
|
||||
Ok(results
|
||||
.into_iter()
|
||||
.map(|r| PayoutId(r.id))
|
||||
.map(|r| DBPayoutId(r.id))
|
||||
.collect::<Vec<_>>())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user