feat(analytics): Add currency as dimension and filter for disputes (#7006)

This commit is contained in:
Sandeep Kumar
2025-02-05 19:04:00 +05:30
committed by GitHub
parent 8d8ebe9051
commit 12a2f2ad14
12 changed files with 41 additions and 2 deletions

View File

@ -4,7 +4,7 @@ use std::{
};
use super::{ForexMetric, NameDescription, TimeRange};
use crate::enums::DisputeStage;
use crate::enums::{Currency, DisputeStage};
#[derive(
Clone,
@ -58,6 +58,7 @@ pub enum DisputeDimensions {
// Consult the Dashboard FE folks since these also affects the order of metrics on FE
Connector,
DisputeStage,
Currency,
}
impl From<DisputeDimensions> for NameDescription {
@ -82,13 +83,17 @@ impl From<DisputeMetrics> for NameDescription {
pub struct DisputeFilters {
#[serde(default)]
pub dispute_stage: Vec<DisputeStage>,
#[serde(default)]
pub connector: Vec<String>,
#[serde(default)]
pub currency: Vec<Currency>,
}
#[derive(Debug, serde::Serialize, Eq)]
pub struct DisputeMetricsBucketIdentifier {
pub dispute_stage: Option<DisputeStage>,
pub connector: Option<String>,
pub currency: Option<Currency>,
#[serde(rename = "time_range")]
pub time_bucket: TimeRange,
#[serde(rename = "time_bucket")]
@ -100,6 +105,7 @@ impl Hash for DisputeMetricsBucketIdentifier {
fn hash<H: Hasher>(&self, state: &mut H) {
self.dispute_stage.hash(state);
self.connector.hash(state);
self.currency.hash(state);
self.time_bucket.hash(state);
}
}
@ -117,11 +123,13 @@ impl DisputeMetricsBucketIdentifier {
pub fn new(
dispute_stage: Option<DisputeStage>,
connector: Option<String>,
currency: Option<Currency>,
normalized_time_range: TimeRange,
) -> Self {
Self {
dispute_stage,
connector,
currency,
time_bucket: normalized_time_range,
start_time: normalized_time_range.start_time,
}