inner instead of left
This commit is contained in:
parent
0181347b42
commit
98bda65735
@ -141,8 +141,8 @@ impl Balance {
|
|||||||
])),
|
])),
|
||||||
"total_spent",
|
"total_spent",
|
||||||
)
|
)
|
||||||
.left_join(rpc_key::Entity)
|
.inner_join(rpc_key::Entity)
|
||||||
// .filter(rpc_key::Column::Id.eq(rpc_accounting_v2::Column::RpcKeyId)) // TODO: i think the left_join function handles this
|
// .filter(rpc_key::Column::Id.eq(rpc_accounting_v2::Column::RpcKeyId)) // TODO: i think the inner_join function handles this
|
||||||
.filter(rpc_key::Column::UserId.eq(user_id))
|
.filter(rpc_key::Column::UserId.eq(user_id))
|
||||||
.into_tuple()
|
.into_tuple()
|
||||||
.one(db_conn)
|
.one(db_conn)
|
||||||
@ -172,7 +172,7 @@ impl Balance {
|
|||||||
])),
|
])),
|
||||||
"credits_applied_for_referrer",
|
"credits_applied_for_referrer",
|
||||||
)
|
)
|
||||||
.left_join(referrer::Entity)
|
.inner_join(referrer::Entity)
|
||||||
.filter(referrer::Column::UserId.eq(user_id))
|
.filter(referrer::Column::UserId.eq(user_id))
|
||||||
.into_tuple()
|
.into_tuple()
|
||||||
.one(db_conn)
|
.one(db_conn)
|
||||||
|
@ -379,9 +379,11 @@ impl BufferedRpcQueryStats {
|
|||||||
|
|
||||||
let mut user_balance = user_balance.write().await;
|
let mut user_balance = user_balance.write().await;
|
||||||
|
|
||||||
|
let premium_before = user_balance.active_premium();
|
||||||
|
|
||||||
// First of all, save the statistics to the database:
|
// First of all, save the statistics to the database:
|
||||||
let paid_credits_used = self
|
let paid_credits_used = self
|
||||||
._save_db_stats(chain_id, db_conn, &key, user_balance.active_premium())
|
._save_db_stats(chain_id, db_conn, &key, premium_before)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// No need to continue if no credits were used
|
// No need to continue if no credits were used
|
||||||
@ -392,8 +394,6 @@ impl BufferedRpcQueryStats {
|
|||||||
|
|
||||||
// Update and possible invalidate rpc caches if necessary (if there was a downgrade)
|
// Update and possible invalidate rpc caches if necessary (if there was a downgrade)
|
||||||
{
|
{
|
||||||
let premium_before = user_balance.active_premium();
|
|
||||||
|
|
||||||
user_balance.total_spent_paid_credits += paid_credits_used;
|
user_balance.total_spent_paid_credits += paid_credits_used;
|
||||||
|
|
||||||
// Invalidate caches if remaining is getting close to $0
|
// Invalidate caches if remaining is getting close to $0
|
||||||
@ -413,7 +413,7 @@ impl BufferedRpcQueryStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if user_balance.active_premium() {
|
if premium_before {
|
||||||
// Start a transaction
|
// Start a transaction
|
||||||
let txn = db_conn.begin().await?;
|
let txn = db_conn.begin().await?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user