Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: analytics minor bugs #1732

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/components/DateRangeCompareFields.res
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ module Base = {

let timeVisibilityClass = showTime ? "block" : "hidden"

let getDiffForPredefined = predefinedDay => {
let getPredefinedValues = predefinedDay => {
let (stDate, enDate, stTime, enTime) = DateRangeUtils.getPredefinedStartAndEndDate(
todayDayJsObj,
isoStringToCustomTimeZone,
Expand Down Expand Up @@ -519,8 +519,21 @@ module Base = {
endDateVal,
"YYYY-MM-DDTHH:mm:00[Z]",
)
let (startTimestamp, endTimestamp) = getDiffForPredefined(item)
(startTimestamp, endTimestamp) == (startDate, endDate)

let (startTimestamp, endTimestamp) = getPredefinedValues(item)

let prestartDate = convertTimeStamp(
~isoStringToCustomTimeZone,
startTimestamp,
"YYYY-MM-DDTHH:mm:00[Z]",
)
let preendDate = convertTimeStamp(
~isoStringToCustomTimeZone,
endTimestamp,
"YYYY-MM-DDTHH:mm:00[Z]",
)

startDate == prestartDate && endDate == preendDate
})

let buttonText = switch predefinedOptionSelected {
Expand Down Expand Up @@ -639,16 +652,6 @@ module Base = {
</AddDataAttributes>
</div>
}
let isPrimaryPredefinedOptionSelected = getIsPredefinedOptionSelected(
predefinedDays,
startDateVal,
endDateVal,
isoStringToCustomTimeZone,
isoStringToCustomTimezoneInFloat,
customTimezoneToISOString,
disableFutureDates,
disablePastDates,
)
let dropDownClass = `absolute ${dropdownPosition} z-20 max-h-min max-w-min overflow-auto bg-white dark:bg-jp-gray-950 rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none mt-2 right-0`
<div ref={dateRangeRef->ReactDOM.Ref.domRef} className="daterangSelection relative">
<DateSelectorButton
Expand All @@ -663,7 +666,7 @@ module Base = {
showTime
buttonText
showSeconds
predefinedOptionSelected=isPrimaryPredefinedOptionSelected
predefinedOptionSelected
disableFutureDates
onClick={_ => handleDropdownClick()}
buttonType
Expand Down
44 changes: 42 additions & 2 deletions src/components/DateRangeField.res
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,33 @@ module Base = {
getStartEndDiff(startTimestamp, endTimestamp)
}

let getPredefinedValues = predefinedDay => {
let (stDate, enDate, stTime, enTime) = DateRangeUtils.getPredefinedStartAndEndDate(
todayDayJsObj,
isoStringToCustomTimeZone,
isoStringToCustomTimezoneInFloat,
customTimezoneToISOString,
predefinedDay,
disableFutureDates,
disablePastDates,
todayDate,
todayTime,
)
let startTimestamp = changeTimeFormat(
~date=stDate,
~time=stTime,
~customTimezoneToISOString,
~format="YYYY-MM-DDTHH:mm:00[Z]",
)
let endTimestamp = changeTimeFormat(
~date=enDate,
~time=enTime,
~customTimezoneToISOString,
~format="YYYY-MM-DDTHH:mm:00[Z]",
)
(startTimestamp, endTimestamp)
}

let predefinedOptionSelected = predefinedDays->Array.find(item => {
let startDate = convertTimeStamp(
~isoStringToCustomTimeZone,
Expand All @@ -598,8 +625,21 @@ module Base = {
endDateVal,
"YYYY-MM-DDTHH:mm:00[Z]",
)
let difference = getStartEndDiff(startDate, endDate)
getDiffForPredefined(item) === difference

let (startTimestamp, endTimestamp) = getPredefinedValues(item)

let prestartDate = convertTimeStamp(
~isoStringToCustomTimeZone,
startTimestamp,
"YYYY-MM-DDTHH:mm:00[Z]",
)
let preendDate = convertTimeStamp(
~isoStringToCustomTimeZone,
endTimestamp,
"YYYY-MM-DDTHH:mm:00[Z]",
)

startDate == prestartDate && endDate == preendDate
})

let buttonText = switch predefinedOptionSelected {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ let paymentsLifeCycleMapper = (
partialRefunded +
(isSmartRetryEnabled ? data.smartRetriedSuccess : 0) +
data.normalSuccess
let failure = data.normalFailure + (isSmartRetryEnabled ? data.smartRetriedFailure * 2 : 0)
let failure = data.normalFailure + (isSmartRetryEnabled ? data.smartRetriedFailure : 0)
let pending = data.pending
let cancelled = data.cancelled
let dropoff =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module PaymentsProcessedHeader = {
->getString("is_smart_retry_enabled", "true")
->getBoolFromString(true)
->getSmartRetryMetricType

let primaryValue = getMetaDataValue(
~data,
~index=0,
Expand Down Expand Up @@ -214,7 +215,7 @@ let make = (
let secondaryData =
secondaryResponse->getDictFromJsonObject->getArrayFromDict("queryData", [])
let secondaryMetaData =
primaryResponse->getDictFromJsonObject->getArrayFromDict("metaData", [])
secondaryResponse->getDictFromJsonObject->getArrayFromDict("metaData", [])
let secondaryModifiedData = [secondaryData]->Array.map(data => {
NewAnalyticsUtils.fillMissingDataPoints(
~data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ let make = (
let secondaryData =
secondaryResponse->getDictFromJsonObject->getArrayFromDict("queryData", [])
let secondaryMetaData =
primaryResponse->getDictFromJsonObject->getArrayFromDict("metaData", [])
secondaryResponse->getDictFromJsonObject->getArrayFromDict("metaData", [])
let secondaryModifiedData = [secondaryData]->Array.map(data => {
NewAnalyticsUtils.fillMissingDataPoints(
~data,
Expand Down
Loading