Files
yara724-api/src/ai/ai-job.schema.ts
T
SepehrYahyaee 755e921c08 feat: replace OpenAI pricing with AI assessment estimates
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.
2026-11-08 10:52:45 +03:30

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 });