Skip to content

Commit

Permalink
fix: Skip processing if segments above 149
Browse files Browse the repository at this point in the history
  • Loading branch information
richiemcilroy committed Jun 4, 2024
1 parent 99e34d0 commit c00bc0c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions apps/web/app/api/upload/mux/create/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,29 @@ export async function GET(request: NextRequest) {
const videoSegmentKeys = (videoSegments.Contents || []).map(
(object) => `s3://${bucket}/${object.Key}`
);

if (videoSegmentKeys.length > 149) {
await db
.update(videos)
.set({ skipProcessing: true })
.where(eq(videos.id, videoId));
return new Response(
JSON.stringify({
message: "Number of inputs exceeds limit, skipping processing",
}),
{
status: 200,
headers: {
"Access-Control-Allow-Origin": allowedOrigins.includes(origin)
? origin
: "null",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Methods": "GET, OPTIONS",
},
}
);
}

const audioSegmentKeys = (audioSegments.Contents || []).map(
(object) => `s3://${bucket}/${object.Key}`
);
Expand Down
1 change: 1 addition & 0 deletions packages/database/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const videos = mysqlTable(
xStreamInfo: text("xStreamInfo"),
jobId: varchar("jobId", { length: 255 }),
jobStatus: varchar("jobStatus", { length: 255 }),
skipProcessing: boolean("skipProcessing").notNull().default(false),
createdAt: timestamp("createdAt").notNull().defaultNow(),
updatedAt: timestamp("updatedAt").notNull().defaultNow().onUpdateNow(),
},
Expand Down

1 comment on commit c00bc0c

@vercel
Copy link

@vercel vercel bot commented on c00bc0c Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.