feat(analytics): AVM v2 batch valuation, comparison, history + frontend upgrade
Add batch valuation (POST /analytics/valuation/batch, max 50 properties), valuation comparison (POST /analytics/valuation/compare, 2-5 properties), and history endpoint (GET /analytics/valuation/history/:propertyId) with confidence explanation helper. Frontend: enhanced valuation form with project autocomplete and deep analysis toggle, results with confidence badges and price range visualization, comparables table, history chart, market context card, and PDF export. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PropertyType } from '@prisma/client';
|
||||
import { PrismaService } from '@modules/shared';
|
||||
import { type PropertyType } from '@prisma/client';
|
||||
import { type PrismaService } from '@modules/shared';
|
||||
import {
|
||||
IAVMService,
|
||||
type IAVMService,
|
||||
type AVMParams,
|
||||
type ValuationResult,
|
||||
type Comparable,
|
||||
type BatchValuationItem,
|
||||
type BatchValuationResult,
|
||||
} from '../../domain/services/avm-service';
|
||||
import {
|
||||
type RawComparable,
|
||||
@@ -68,6 +70,19 @@ export class PrismaAVMService implements IAVMService {
|
||||
return raws.map(toComparableDto);
|
||||
}
|
||||
|
||||
async estimateBatch(items: BatchValuationItem[]): Promise<BatchValuationResult[]> {
|
||||
return Promise.all(
|
||||
items.map(async (item) => {
|
||||
try {
|
||||
const valuation = await this.estimateValue({ propertyId: item.propertyId });
|
||||
return { propertyId: item.propertyId, valuation };
|
||||
} catch {
|
||||
return { propertyId: item.propertyId, valuation: null, error: 'Lỗi định giá' };
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
private async resolveParams(params: AVMParams): Promise<{
|
||||
lat: number; lng: number; areaM2: number;
|
||||
propertyType: PropertyType | undefined;
|
||||
|
||||
Reference in New Issue
Block a user