mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
feat(analytics): Add refund sessionized metrics for Analytics V2 dashboard (#6616)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -154,6 +154,7 @@ impl super::payment_intents::filters::PaymentIntentFilterAnalytics for SqlxClien
|
||||
impl super::payment_intents::metrics::PaymentIntentMetricAnalytics for SqlxClient {}
|
||||
impl super::refunds::metrics::RefundMetricAnalytics for SqlxClient {}
|
||||
impl super::refunds::filters::RefundFilterAnalytics for SqlxClient {}
|
||||
impl super::refunds::distribution::RefundDistributionAnalytics for SqlxClient {}
|
||||
impl super::disputes::filters::DisputeFilterAnalytics for SqlxClient {}
|
||||
impl super::disputes::metrics::DisputeMetricAnalytics for SqlxClient {}
|
||||
impl super::frm::metrics::FrmMetricAnalytics for SqlxClient {}
|
||||
@ -214,6 +215,15 @@ impl<'a> FromRow<'a, PgRow> for super::refunds::metrics::RefundMetricRow {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let refund_reason: Option<String> = row.try_get("refund_reason").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let refund_error_message: Option<String> =
|
||||
row.try_get("refund_error_message").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let total: Option<bigdecimal::BigDecimal> = row.try_get("total").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
@ -235,6 +245,8 @@ impl<'a> FromRow<'a, PgRow> for super::refunds::metrics::RefundMetricRow {
|
||||
connector,
|
||||
refund_type,
|
||||
profile_id,
|
||||
refund_reason,
|
||||
refund_error_message,
|
||||
total,
|
||||
count,
|
||||
start_bucket,
|
||||
@ -791,12 +803,88 @@ impl<'a> FromRow<'a, PgRow> for super::refunds::filters::RefundFilterRow {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let refund_reason: Option<String> = row.try_get("refund_reason").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let refund_error_message: Option<String> =
|
||||
row.try_get("refund_error_message").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
Ok(Self {
|
||||
currency,
|
||||
refund_status,
|
||||
connector,
|
||||
refund_type,
|
||||
profile_id,
|
||||
refund_reason,
|
||||
refund_error_message,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromRow<'a, PgRow> for super::refunds::distribution::RefundDistributionRow {
|
||||
fn from_row(row: &'a PgRow) -> sqlx::Result<Self> {
|
||||
let currency: Option<DBEnumWrapper<Currency>> =
|
||||
row.try_get("currency").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let refund_status: Option<DBEnumWrapper<RefundStatus>> =
|
||||
row.try_get("refund_status").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let connector: Option<String> = row.try_get("connector").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let refund_type: Option<DBEnumWrapper<RefundType>> =
|
||||
row.try_get("refund_type").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let profile_id: Option<String> = row.try_get("profile_id").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let total: Option<bigdecimal::BigDecimal> = row.try_get("total").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let count: Option<i64> = row.try_get("count").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let refund_reason: Option<String> = row.try_get("refund_reason").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
let refund_error_message: Option<String> =
|
||||
row.try_get("refund_error_message").or_else(|e| match e {
|
||||
ColumnNotFound(_) => Ok(Default::default()),
|
||||
e => Err(e),
|
||||
})?;
|
||||
// Removing millisecond precision to get accurate diffs against clickhouse
|
||||
let start_bucket: Option<PrimitiveDateTime> = row
|
||||
.try_get::<Option<PrimitiveDateTime>, _>("start_bucket")?
|
||||
.and_then(|dt| dt.replace_millisecond(0).ok());
|
||||
let end_bucket: Option<PrimitiveDateTime> = row
|
||||
.try_get::<Option<PrimitiveDateTime>, _>("end_bucket")?
|
||||
.and_then(|dt| dt.replace_millisecond(0).ok());
|
||||
Ok(Self {
|
||||
currency,
|
||||
refund_status,
|
||||
connector,
|
||||
refund_type,
|
||||
profile_id,
|
||||
total,
|
||||
count,
|
||||
refund_reason,
|
||||
refund_error_message,
|
||||
start_bucket,
|
||||
end_bucket,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user