Skip to content

Commit

Permalink
rename func
Browse files Browse the repository at this point in the history
  • Loading branch information
codemist committed Oct 28, 2024
1 parent 57decbc commit e867bb9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/emails/components/EmailDataPointCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DashboardSummary } from "../../app/functions/server/dashboard";
import { getSignupLocaleCountry } from "../functions/getSignupLocaleCountry";
import { isEligibleForPremium } from "../../app/functions/universal/premium";
import { SanitizedSubscriberRow } from "../../app/functions/server/sanitize";
import { calculateSanitizedDataPoints } from "../functions/reduceSanitizedDataPoints";
import { sumSanitizedDataPoints } from "../functions/reduceSanitizedDataPoints";

type Props = {
l10n: ExtendedReactLocalization;
Expand Down Expand Up @@ -66,7 +66,7 @@ export const DataPointCount = (props: Props) => {
line-height="68px"
>
{hasRunFreeScan
? calculateSanitizedDataPoints(
? sumSanitizedDataPoints(
props.dataSummary.unresolvedSanitizedDataPoints,
)
: unresolvedDataBreaches}
Expand All @@ -84,7 +84,7 @@ export const DataPointCount = (props: Props) => {
: "email-monthly-report-no-scan-results-data-points-label",
{
data_point_count: hasRunFreeScan
? calculateSanitizedDataPoints(
? sumSanitizedDataPoints(
props.dataSummary.unresolvedSanitizedDataPoints,
)
: unresolvedDataBreaches,
Expand Down
2 changes: 1 addition & 1 deletion src/emails/functions/reduceSanitizedDataPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// data is inteferred from the SanitizedDataPoints type, but we ran into inference issues directly importing it
export function calculateSanitizedDataPoints(
export function sumSanitizedDataPoints(
data: Array<Record<string, number>>,
): number {
return data.reduce((accumulatedValue, currentDataPoint) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { isEligibleForPremium } from "../../../app/functions/universal/premium";
import { getSignupLocaleCountry } from "../../functions/getSignupLocaleCountry";
import { HeaderStyles, MetaTags } from "../HeaderStyles";
import { SanitizedSubscriberRow } from "../../../app/functions/server/sanitize";
import { calculateSanitizedDataPoints } from "../../functions/reduceSanitizedDataPoints";
import { sumSanitizedDataPoints } from "../../functions/reduceSanitizedDataPoints";

export type MonthlyActivityFreeEmailProps = {
l10n: ExtendedReactLocalization;
Expand Down Expand Up @@ -79,16 +79,15 @@ export const MonthlyActivityFreeEmail = (
// Show a sum of resolved data breach & broker exposures if a scan has been run
// Otherwise, only show resolved data breaches
dataPointValue: hasRunFreeScan
? calculateSanitizedDataPoints(props.dataSummary.fixedSanitizedDataPoints)
? sumSanitizedDataPoints(props.dataSummary.fixedSanitizedDataPoints)
: props.dataSummary.dataBreachResolvedNum,
// The resolved box would be active if
// a user has run a free scan and they have resolved data breaches, and or brokers (count number of resolved data points)
// if a user hasn't run a free scan but they have resolved data breaches (count number of resolved breach cards)
activeState:
(hasRunFreeScan &&
calculateSanitizedDataPoints(
props.dataSummary.fixedSanitizedDataPoints,
) > 0) ||
sumSanitizedDataPoints(props.dataSummary.fixedSanitizedDataPoints) >
0) ||
(!hasRunFreeScan && props.dataSummary.dataBreachResolvedNum > 0),
};

Expand All @@ -99,7 +98,7 @@ export const MonthlyActivityFreeEmail = (
preScan: !hasRunFreeScan && props.dataSummary.dataBreachUnresolvedNum === 0,
postScan:
hasRunFreeScan &&
calculateSanitizedDataPoints(
sumSanitizedDataPoints(
props.dataSummary.unresolvedSanitizedDataPoints,
) === 0,
};
Expand Down

0 comments on commit e867bb9

Please sign in to comment.