forked from Yara724/api
Added AI damage helper
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
||||
import { Schema as MongoSchema } from "mongoose";
|
||||
import { AiResult } from "./ai-result";
|
||||
|
||||
@Schema({ collection: "ai-damage-jobs", timestamps: true, versionKey: false })
|
||||
export class AiJob {
|
||||
@Prop({ required: true }) claimId: string;
|
||||
@Prop({ required: true }) imageKey: string;
|
||||
@Prop({ required: true }) path: string;
|
||||
@Prop() fileName?: string;
|
||||
@Prop({
|
||||
default: "queued",
|
||||
enum: ["queued", "processing", "completed", "failed"],
|
||||
})
|
||||
status: string;
|
||||
@Prop({ default: 0 }) attempts: number;
|
||||
@Prop({ default: () => new Date() }) nextAttemptAt: Date;
|
||||
@Prop() leaseUntil?: Date;
|
||||
@Prop() leaseToken?: string;
|
||||
@Prop() completedAt?: Date;
|
||||
@Prop() error?: string;
|
||||
@Prop({ type: MongoSchema.Types.Mixed }) result?: AiResult;
|
||||
}
|
||||
export const AiJobSchema = SchemaFactory.createForClass(AiJob);
|
||||
AiJobSchema.index({ claimId: 1, imageKey: 1 }, { unique: true });
|
||||
AiJobSchema.index({ status: 1, nextAttemptAt: 1, leaseUntil: 1 });
|
||||
Reference in New Issue
Block a user