forked from Yara724/api
Extend durable image assessments with explicit Persian vehicle names, deployment severity settings and advisory market prices normalized to rials. Preserve case access and retry boundaries, and remove the retired OpenAI pricing module and routes.
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
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() carName?: string;
|
|
@Prop({ default: false }) includePrices?: boolean;
|
|
@Prop() priceMinSeverity?: 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() errorCode?: string;
|
|
@Prop() errorRequestId?: 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 });
|