Skip to content

Commit

Permalink
more info in Balance's Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
BlinkyStitt committed Jul 21, 2023
1 parent e6666d9 commit 044d19e
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion web3_proxy/src/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ use migration::{Func, SimpleExpr};
use serde::ser::SerializeStruct;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::fmt::Debug;
use tracing::trace;

/// Implements the balance getter which combines data from several tables
#[derive(Clone, Debug, Default, Deserialize)]
#[derive(Clone, Default, Deserialize)]
pub struct Balance {
pub admin_deposits: Decimal,
pub chain_deposits: Decimal,
Expand All @@ -32,6 +33,32 @@ pub struct Balance {
pub downgrade_tier_id: Option<u64>,
}

impl Debug for Balance {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Balance")
// normal fields
.field("admin_deposits", &self.admin_deposits)
.field("chain_deposits", &self.chain_deposits)
.field("one_time_referee_bonus", &self.one_time_referee_bonus)
.field("referal_bonus", &self.referal_bonus)
.field("stripe_deposits", &self.stripe_deposits)
.field("total_cache_misses", &self.total_cache_misses)
.field("total_frontend_requests", &self.total_frontend_requests)
.field("total_spent", &self.total_spent)
.field("total_spent_paid_credits", &self.total_spent_paid_credits)
.field("user_id", &self.user_id)
.field("user_tier_id", &self.user_tier_id)
.field("downgrade_tier_id", &self.downgrade_tier_id)
// extra things
.field("active_premium", &self.active_premium())
.field("was_ever_premium", &self.was_ever_premium())
.field("balance", &self.remaining())
.field("total_deposits", &self.total_deposits())
// done
.finish()
}
}

impl Serialize for Balance {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down

0 comments on commit 044d19e

Please sign in to comment.