Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore: retry recent csv exports (#9889)

Max Deichmannf08593647ec0
diff --git a/worker/src/features/batchExport/handleBatchExportJob.ts b/worker/src/features/batchExport/handleBatchExportJob.ts
index 551ef0e9ab..1058b68a98 100644
--- a/worker/src/features/batchExport/handleBatchExportJob.ts
+++ b/worker/src/features/batchExport/handleBatchExportJob.ts
@@ -56,6 +56,35 @@ export const handleBatchExportJob = async (
`Job not found for project: ${projectId} and export ${batchExportId}`,
);
}
+
+ // Check if the batch export is older than 30 days
+ const thirtyDaysAgo = new Date();
+ thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
+
+ if (jobDetails.createdAt < thirtyDaysAgo) {
+ // For old exports, mark as failed with an informative message
+ const improvedExportMessage =
+ "We have improved the batch export feature. Please retry your export to benefit from the latest enhancements.";
+
+ await prisma.batchExport.update({
+ where: {
+ id: batchExportId,
+ projectId,
+ },
+ data: {
+ status: BatchExportStatus.FAILED,
+ finishedAt: new Date(),
+ log: improvedExportMessage,
+ },
+ });
+
+ logger.info(
+ `Batch export ${batchExportId} is older than 30 days. Marked as failed with retry message.`,
+ );
+
+ return; // Exit early without processing
+ }
+
if (jobDetails.status !== BatchExportStatus.QUEUED) {
logger.warn(
`Job ${batchExportId} has invalid status: ${jobDetails.status}. Retrying anyway.`,