credits helpers
This commit is contained in:
parent
4601852c0c
commit
7454c1a256
7
docs/sum_credits_used_by_user.sql
Normal file
7
docs/sum_credits_used_by_user.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
SELECT SUM(`sum_credits_used`) as sum, rpc_accounting_v2.rpc_key_id, rpc_key.user_id, user.email
|
||||||
|
FROM `rpc_accounting_v2`
|
||||||
|
JOIN rpc_key ON rpc_accounting_v2.rpc_key_id=rpc_key.id
|
||||||
|
JOIN user on rpc_key.user_id=user.id
|
||||||
|
GROUP BY `rpc_key_id`
|
||||||
|
ORDER BY sum DESC
|
||||||
|
LIMIT 100
|
@ -26,6 +26,10 @@ pub struct GrantCreditsToAddress {
|
|||||||
#[argh(positional)]
|
#[argh(positional)]
|
||||||
/// how many credits to give. "0" to just see their balance
|
/// how many credits to give. "0" to just see their balance
|
||||||
credits: Decimal,
|
credits: Decimal,
|
||||||
|
|
||||||
|
#[argh(option)]
|
||||||
|
/// description of the transaction.
|
||||||
|
note: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GrantCreditsToAddress {
|
impl GrantCreditsToAddress {
|
||||||
@ -52,7 +56,10 @@ impl GrantCreditsToAddress {
|
|||||||
// TODO: allow customizing the admin id
|
// TODO: allow customizing the admin id
|
||||||
admin_id: sea_orm::Set(1),
|
admin_id: sea_orm::Set(1),
|
||||||
deposit_to_user_id: sea_orm::Set(user_id),
|
deposit_to_user_id: sea_orm::Set(user_id),
|
||||||
note: sea_orm::Set("grant credits to address".into()),
|
note: sea_orm::Set(
|
||||||
|
self.note
|
||||||
|
.unwrap_or_else(|| "grant credits to address".to_string()),
|
||||||
|
),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
increase_balance_receipt.save(&txn).await?;
|
increase_balance_receipt.save(&txn).await?;
|
||||||
|
Loading…
Reference in New Issue
Block a user