Skip to content

Commit

Permalink
added connector successrate
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarnaikjuspay committed Nov 28, 2023
1 parent db65e36 commit dfc382b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/screens/HyperSwitch/Analytics/AnalyticsTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ type paymentsSingleState = {
payment_success_count: int,
retries_count: int,
retries_amount_processe: float,
connector_success_rate: float,
payment_processed_amount: float,
payment_avg_ticket_size: float,
}
Expand All @@ -166,6 +167,7 @@ type paymentsSingleStateSeries = {
payment_count: int,
retries_count: int,
retries_amount_processe: float,
connector_success_rate: float,
payment_success_count: int,
time_series: string,
payment_processed_amount: float,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ let singleStateInitialValue = {
retries_count: 0,
retries_amount_processe: 0.0,
payment_success_count: 0,
connector_success_rate: 0.0,
payment_processed_amount: 0.0,
payment_avg_ticket_size: 0.0,
}
Expand All @@ -240,6 +241,7 @@ let singleStateSeriesInitialValue = {
payment_success_count: 0,
time_series: "",
payment_processed_amount: 0.0,
connector_success_rate: 0.0,
payment_avg_ticket_size: 0.0,
}

Expand All @@ -255,6 +257,7 @@ let singleStateItemToObjMapper = json => {
payment_avg_ticket_size: dict->getFloat("avg_ticket_size", 0.0),
retries_count: dict->getInt("retries_count", 0),
retries_amount_processe: dict->getFloat("retries_amount_processed", 0.0),
connector_success_rate: dict->getFloat("connector_success_rate", 0.0),
})
->Belt.Option.getWithDefault({
singleStateInitialValue
Expand All @@ -274,6 +277,7 @@ let singleStateSeriesItemToObjMapper = json => {
payment_avg_ticket_size: dict->getFloat("avg_ticket_size", 0.0)->setPrecision(),
retries_count: dict->getInt("retries_count", 0),
retries_amount_processe: dict->getFloat("retries_amount_processed", 0.0),
connector_success_rate: dict->getFloat("connector_success_rate", 0.0),
})
->getWithDefault({
singleStateSeriesInitialValue
Expand All @@ -299,6 +303,7 @@ type colT =
| AvgTicketSize
| RetriesCount
| RetriesAmountProcessed
| ConnectorSuccessRate

let defaultColumns: array<DynamicSingleStat.columns<colT>> = [
{
Expand All @@ -311,6 +316,7 @@ let defaultColumns: array<DynamicSingleStat.columns<colT>> = [
AvgTicketSize,
RetriesCount,
RetriesAmountProcessed,
ConnectorSuccessRate,
],
},
]
Expand Down Expand Up @@ -376,6 +382,10 @@ let constructData = (
ob.retries_amount_processe /. 100.00,
))
->Js.Array2.sortInPlaceWith(compareLogic)
| "connector_success_rate" =>
singlestatTimeseriesData
->Js.Array2.map(ob => (ob.time_series->DateTimeUtils.parseAsFloat, ob.connector_success_rate))
->Js.Array2.sortInPlaceWith(compareLogic)
| _ => []
}
}
Expand Down Expand Up @@ -513,6 +523,21 @@ let getStatData = (
statType: "Amount",
showDelta: false,
}
| ConnectorSuccessRate => {
title: "Payment success rate",
tooltipText: "Total successful payments processed out of all user confirmed payments",
deltaTooltipComponent: AnalyticsUtils.singlestatDeltaTooltipFormat(
singleStatData.connector_success_rate,
deltaTimestampData.currentSr,
),
value: singleStatData.connector_success_rate,
delta: {
singleStatData.connector_success_rate
},
data: constructData("connector_success_rate", timeSeriesData),
statType: "Rate",
showDelta: false,
}
}
}

Expand Down

0 comments on commit dfc382b

Please sign in to comment.