Skip to content

Commit

Permalink
Update route.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
devkiran committed Mar 10, 2025
1 parent 33a825d commit 04c752d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions apps/web/app/api/cron/import/csv/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { createId } from "@/lib/api/create-id";
import { addDomainToVercel } from "@/lib/api/domains";
import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { bulkCreateLinks, createLink, processLink } from "@/lib/api/links";
import { qstash } from "@/lib/cron";
import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
import { storage } from "@/lib/storage";
import { ProcessedLinkProps, WorkspaceProps } from "@/lib/types";
Expand All @@ -12,7 +11,6 @@ import { createLinkBodySchema } from "@/lib/zod/schemas/links";
import { randomBadgeColor } from "@/ui/links/tag-badge";
import { prisma } from "@dub/prisma";
import {
APP_DOMAIN_WITH_NGROK,
DEFAULT_LINK_PROPS,
DUB_DOMAINS_ARRAY,
linkConstructorSimple,
Expand Down Expand Up @@ -57,7 +55,7 @@ interface ErrorLink {
error: string;
}

const MAX_ROWS_PER_EXECUTION = 100;
const MAX_ROWS_PER_EXECUTION = 50;

// POST /api/cron/import/csv
export async function POST(req: Request) {
Expand Down Expand Up @@ -134,10 +132,10 @@ export async function POST(req: Request) {

// If we processed the maximum rows and haven't reached the end, trigger next batch
if (currentRow - cursor >= MAX_ROWS_PER_EXECUTION && !isComplete) {
await qstash.publishJSON({
url: `${APP_DOMAIN_WITH_NGROK}/api/cron/import/csv`,
body: payload,
});
// await qstash.publishJSON({
// url: `${APP_DOMAIN_WITH_NGROK}/api/cron/import/csv`,
// body: payload,
// });
} else {
const errorLinks = await redis.lrange<ErrorLink>(
`${redisKey}:failed`,
Expand Down Expand Up @@ -318,8 +316,6 @@ const processMappedLinks = async ({
result.success && !!result.data,
);

console.log(successfulMappings);

// Process the tags
let selectedTags = successfulMappings
.map((result) => result.data.tags || [])
Expand Down Expand Up @@ -357,10 +353,12 @@ const processMappedLinks = async ({
}

// Process the domains
const selectedDomains = successfulMappings
let selectedDomains = successfulMappings
.map((result) => result.data.domain)
.filter((domain): domain is string => Boolean(domain));

selectedDomains = [...new Set(selectedDomains)];

const domains = await prisma.domain.findMany({
where: {
projectId: workspaceId,
Expand Down

0 comments on commit 04c752d

Please sign in to comment.