Skip to content

Commit

Permalink
chore: smart retry changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarnaikjuspay committed Jul 10, 2024
1 parent da18546 commit 71c3c91
Show file tree
Hide file tree
Showing 5 changed files with 332 additions and 34 deletions.
7 changes: 4 additions & 3 deletions src/components/DynamicSingleStat.res
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ let make = (
let homePageCss = isHomePage || chartAlignment === #row ? "flex-col" : "flex-row"
let wrapperClass =
wrapperClass->Option.getOr(
`flex flex-col md:${homePageCss} flex-wrap justify-start items-stretch relative`,
`flex flex-col md:${homePageCss} flex-wrap justify-start items-stretch relative h-full`,
)

let (singleStatData, setSingleStatData) = React.useState(() => None)
Expand Down Expand Up @@ -492,6 +492,7 @@ let make = (
filterNullVals
?statSentiment
?statThreshold
fullWidth={columns->Array.length == 1}
/>

| None =>
Expand Down Expand Up @@ -628,8 +629,8 @@ let make = (
attributes=[("data-dynamic-single-stats", "dynamic stats")] key={index->Int.toString}>
<div className=wrapperClass>
{if isMobileView {
<div className="flex flex-col gap-2 items-center">
<div className="flex flex-wrap w-full">
<div className="flex flex-col gap-2 items-center h-full">
<div className="flex flex-wrap w-full h-full">
{singleStateArr
->Array.mapWithIndex((element, index) => {
<RenderIf condition={index < 4 || showStats} key={index->Int.toString}>
Expand Down
18 changes: 11 additions & 7 deletions src/components/HSwitchSingleStatTableWidget.res
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ let make = (
~filterNullVals: bool=false,
~statSentiment: Dict.t<AnalyticsUtils.statSentiment>=Dict.make(),
~statThreshold: Dict.t<float>=Dict.make(),
~fullWidth=false,
) => {
let isMobileWidth = MatchMedia.useMatchMedia("(max-width: 700px)")

Expand All @@ -172,16 +173,19 @@ let make = (
(),
)

let modifiedData = value->Array.filter(val => val.rowValue > 0.0)

if singleStatLoading && loaderType === Shimmer {
<div className={`p-4`} style={ReactDOMStyle.make(~width=isMobileWidth ? "100%" : "33.33%", ())}>
<Shimmer styleClass="w-full h-28" />
</div>
} else {
<div
className={`mt-4`} style={ReactDOMStyle.make(~width=isMobileWidth ? "100%" : "33.33%", ())}>
className={`mt-4`}
style={ReactDOMStyle.make(~width=fullWidth ? "100%" : isMobileWidth ? "100%" : "33.33%", ())}>
<div
className={`h-full flex flex-col border ${borderRounded} dark:border-jp-gray-850 bg-white dark:bg-jp-gray-lightgray_background overflow-hidden singlestatBox p-2 md:mr-4`}>
<div className="p-4 flex flex-col justify-between h-full gap-2">
<div className="p-4 flex flex-col justify-start h-full gap-2">
<UIUtils.RenderIf condition={singleStatLoading && loaderType === SideLoader}>
<div className="animate-spin self-end absolute">
<Icon name="spinner" size=16 />
Expand All @@ -201,10 +205,10 @@ let make = (
/>
</div>
<div className="flex gap-1 flex-col w-full mt-1">
{if value->Array.length > 0 {
{if modifiedData->Array.length > 0 {
<>
{value
->Array.filterWithIndex((_val, index) => index < 5)
{modifiedData
->Array.filterWithIndex((_val, index) => index < 3)
->Array.mapWithIndex((item, index) => {
<div
key={index->Int.toString}
Expand All @@ -214,8 +218,8 @@ let make = (
</div>
})
->React.array}
<UIUtils.RenderIf condition={value->Array.length > 5}>
<ShowMore value title tableEntity />
<UIUtils.RenderIf condition={modifiedData->Array.length > 5}>
<ShowMore value=modifiedData title tableEntity />
</UIUtils.RenderIf>
</>
} else {
Expand Down
14 changes: 1 addition & 13 deletions src/screens/Analytics/PaymentsAnalytics/PaymentAnalytics.res
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ let make = () => {
"avg_ticket_size",
"payment_processed_amount",
]
let smartRetrieMetrics = ["retries_count"]

let formatMetrics = arrMetrics => {
arrMetrics->Array.map(metric => {
Expand Down Expand Up @@ -260,18 +259,7 @@ let make = () => {
moduleName="payments_analytics_amount"
formaPayload
/>
<MetricsState
heading="Smart Retries"
singleStatEntity={getSingleStatEntity(
smartRetrieMetrics->formatMetrics,
smartRetrivesColumns,
)}
filterKeys=tabKeys
startTimeFilterKey
endTimeFilterKey
moduleName="smart_retries"
formaPayload
/>
<SmartRetryAnalytics filterKeys=tabKeys moduleName="payments_smart_retries" />
<OverallSummary
filteredTabVales=tabValues
moduleName="overall_summary"
Expand Down
31 changes: 20 additions & 11 deletions src/screens/Analytics/PaymentsAnalytics/PaymentAnalyticsEntity.res
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,9 @@ type colT =
| SuccessCount
| ProcessedAmount
| AvgTicketSize
| RetriesCount
| RetriesAmountProcessed
| SuccessfulSmartRetries
| TotalSmartRetries
| SmartRetriedAmount
| ConnectorSuccessRate

let generalMetricsColumns: array<DynamicSingleStat.columns<colT>> = [
Expand All @@ -345,13 +346,6 @@ let amountMetricsColumns: array<DynamicSingleStat.columns<colT>> = [
},
]

let smartRetrivesColumns: array<DynamicSingleStat.columns<colT>> = [
{
sectionName: "",
columns: [RetriesCount, RetriesAmountProcessed]->generateDefaultStateColumns,
},
]

let compareLogic = (firstValue, secondValue) => {
let (temp1, _) = firstValue
let (temp2, _) = secondValue
Expand Down Expand Up @@ -509,7 +503,7 @@ let getStatData = (
showDelta: false,
label: singleStatData.currency,
}
| RetriesCount => {
| TotalSmartRetries => {
title: "Smart Retries made",
tooltipText: "Total number of retries that were attempted after a failed payment attempt (Note: Only date range filters are supoorted currently)",
deltaTooltipComponent: AnalyticsUtils.singlestatDeltaTooltipFormat(
Expand All @@ -524,7 +518,22 @@ let getStatData = (
statType: "Volume",
showDelta: false,
}
| RetriesAmountProcessed => {
| SuccessfulSmartRetries => {
title: "Successful Smart Retries",
tooltipText: "Total number of retries that were attempted after a failed payment attempt (Note: Only date range filters are supoorted currently)",
deltaTooltipComponent: AnalyticsUtils.singlestatDeltaTooltipFormat(
singleStatData.retries_count->Int.toFloat,
deltaTimestampData.currentSr,
),
value: singleStatData.retries_count->Int.toFloat,
delta: {
singleStatData.retries_count->Int.toFloat
},
data: constructData("retries_count", timeSeriesData),
statType: "Volume",
showDelta: false,
}
| SmartRetriedAmount => {
title: `Smart Retries Savings`,
tooltipText: "Total savings in amount terms from retrying failed payments again through a second processor (Note: Only date range filters are supoorted currently)",
deltaTooltipComponent: AnalyticsUtils.singlestatDeltaTooltipFormat(
Expand Down
Loading

0 comments on commit 71c3c91

Please sign in to comment.