Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

update comments / cron

Steven Teyd484a1188c37
diff --git a/apps/web/app/api/cron/fx-rates/route.ts b/apps/web/app/api/cron/fx-rates/route.ts
index 658d8805eb..1e2b5a973a 100644
--- a/apps/web/app/api/cron/fx-rates/route.ts
+++ b/apps/web/app/api/cron/fx-rates/route.ts
@@ -7,7 +7,7 @@ import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
// Cron to update the Foreign Exchange Rates in Redis
-// Runs once every day at 00:00 (0 0 * * *)
+// Runs once every day at 08:00 AM UTC (0 8 * * *)
export async function GET(req: Request) {
try {
await verifyVercelSignature(req);
diff --git a/apps/web/app/api/track/sale/route.ts b/apps/web/app/api/track/sale/route.ts
index 6d380bd6bc..dd4ff64cab 100644
--- a/apps/web/app/api/track/sale/route.ts
+++ b/apps/web/app/api/track/sale/route.ts
@@ -95,12 +95,13 @@ export const POST = withWorkspace(
.omit({ timestamp: true })
.parse(leadEvent.data[0]);
- // if currency is not USD, convert it to USD
+ // if currency is not USD, convert it to USD based on the current FX rate
+ // TODO: allow custom "defaultCurrency" on workspace table in the future
if (currency !== "usd") {
const fxRates = await redis.hget("fxRates:usd", currency.toUpperCase()); // e.g. for MYR it'll be around 4.4
if (fxRates) {
currency = "usd";
- // convert amount to USD (in cents) based on the FX rate
+ // convert amount to USD (in cents) based on the current FX rate
// round it to 0 decimal places
amount = Math.round(amount / Number(fxRates));
}
diff --git a/apps/web/vercel.json b/apps/web/vercel.json
index d3091c3b72..5c0e2a7f1d 100644
--- a/apps/web/vercel.json
+++ b/apps/web/vercel.json
@@ -16,6 +16,10 @@
"path": "/api/cron/disposable-emails",
"schedule": "0 12 * * 1"
},
+ {
+ "path": "/api/cron/fx-rates",
+ "schedule": "0 8 * * *"
+ },
{
"path": "/api/cron/payouts/clicks",
"schedule": "0 0,12 * * *"