Skip to content

Commit bb25b00

Browse files
authored
fix: uses formatDistanceToNow instead of differenceInX to calc time left (#2112)
1 parent 7fedad6 commit bb25b00

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

apps/api/src/notifications/services/notification-templates/before-close-trial-deployment.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { differenceInHours } from "date-fns";
1+
import { formatDistanceToNow } from "date-fns";
22

33
import type { UserOutput } from "@src/user/repositories";
44
import type { CreateNotificationInput } from "../notification/notification.service";
@@ -8,12 +8,12 @@ export function beforeCloseTrialDeploymentNotification(
88
vars: { deploymentClosedAt: string; dseq: string; owner: string }
99
): CreateNotificationInput {
1010
const deploymentClosedAt = new Date(vars.deploymentClosedAt);
11-
const timeLeft = deploymentClosedAt.getTime() < Date.now() ? 0 : differenceInHours(deploymentClosedAt, new Date());
11+
const timeLeft = deploymentClosedAt.getTime() < Date.now() ? "in a few seconds" : formatDistanceToNow(deploymentClosedAt, { addSuffix: true });
1212
return {
13-
notificationId: `beforeCloseTrialDeployment.${timeLeft}.${vars.dseq}.${vars.owner}`,
13+
notificationId: `beforeCloseTrialDeployment.${deploymentClosedAt.toISOString()}.${vars.dseq}.${vars.owner}`,
1414
payload: {
1515
summary: "Your Trial Deployment Ends Soon",
16-
description: `Your trial deployment will end in ${timeLeft} hours. To keep your deployment running, please add a payment method and top up your account before then.`
16+
description: `Your trial deployment will end ${timeLeft}. To keep your deployment running, please add a payment method and top up your account before then.`
1717
},
1818
user: {
1919
id: user.id,

apps/api/src/notifications/services/notification-templates/before-trial-ends-notification.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { differenceInDays } from "date-fns";
1+
import { formatDistanceToNow } from "date-fns";
22

33
import type { ResolvedValue } from "@src/notifications/services/notification-data-resolver/notification-data-resolver.service";
44
import type { UserOutput } from "@src/user/repositories";
@@ -9,13 +9,13 @@ export function beforeTrialEndsNotification(
99
vars: { trialEndsAt: string; paymentLink: string; remainingCredits: ResolvedValue<number>; activeDeployments: ResolvedValue<number> }
1010
): CreateNotificationInput {
1111
const trialEndsDate = new Date(vars.trialEndsAt);
12-
const daysLeft = trialEndsDate.getTime() < Date.now() ? 0 : differenceInDays(trialEndsDate, new Date());
12+
const timeLeft = trialEndsDate.getTime() < Date.now() ? "in a few seconds" : formatDistanceToNow(trialEndsDate, { addSuffix: true });
1313
return {
14-
notificationId: `beforeTrialEnds.${daysLeft}.${user.id}`,
14+
notificationId: `beforeTrialEnds.${trialEndsDate.toISOString()}.${user.id}`,
1515
payload: {
1616
summary: "Your Free Trial is Ending Soon",
1717
description:
18-
`Your free trial with Akash Network will end in ${daysLeft} days. You still have $${vars.remainingCredits} in free credits available and, ` +
18+
`Your free trial with Akash Network will end ${timeLeft}. You still have $${vars.remainingCredits} in free credits available and, ` +
1919
`${vars.activeDeployments} deployments that will be lost when your free trial ends. ` +
2020
`To retain the remaining free credits and to ensure your deployments keep running when the trial ends, purchase some credits today by visiting <a href="${vars.paymentLink}">Akash Console Payment Setup</a>.`
2121
},

apps/stats-web/deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ version: "2.0"
33

44
services:
55
web:
6-
image: baktun/akash-stats:<version>
7-
env:
6+
image: ghcr.io/akash-network/stats-web:<version>
7+
# env:
88
# - API_BASE_URL=<API_URL_OVERRIDE>
99
# - NEXT_PUBLIC_GA_MEASUREMENT_ID=<GA_MEASUREMENT_ID>
1010
# - NEXT_PUBLIC_SENTRY_DSN=<SENTRY_DSN>

0 commit comments

Comments
 (0)