Shun Miyazawa 1 yıl önce
ebeveyn
işleme
a109eb679d

+ 2 - 1
apps/app/src/features/openai/server/models/thread-relation.ts

@@ -44,7 +44,8 @@ const schema = new Schema<ThreadRelationDocument, ThreadRelationModel>({
 });
 
 schema.statics.getExpiredThreadRelations = async function(limit?: number): Promise<ThreadRelationDocument[] | undefined> {
-  const expiredThreadRelations = await this.find({ expiredAt: { $lte: new Date() } }).limit(limit ?? 100).exec();
+  const currentDate = new Date();
+  const expiredThreadRelations = await this.find({ expiredAt: { $lte: currentDate } }).limit(limit ?? 100).exec();
   return expiredThreadRelations;
 };
 

+ 2 - 5
apps/app/src/features/openai/server/services/thread-deletion-cron.ts

@@ -38,11 +38,8 @@ class ThreadDeletionCronService {
     this.cronJob.start();
   }
 
-  stopCron(): void {
-    this.cronJob.stop();
-  }
-
-  async executeJob(): Promise<void> {
+  private async executeJob(): Promise<void> {
+    // Delete only 100 by rateLimit countermeasure on OpenAI side
     await this.openaiService.deleteExpiredThreads(DELETE_LIMIT);
   }