fix(api): usar dossier de actividad resiliente
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ActivityDossierService } from './activity-dossier.service';
|
||||
import { AssetsService } from './assets.service';
|
||||
import { InventoryFunctionService } from './inventory-function.service';
|
||||
import { InventoryMergeService } from './inventory-merge.service';
|
||||
@@ -31,6 +32,7 @@ function sortDesc(items: LooseRecord[], fieldCandidates: string[]): LooseRecord[
|
||||
export class MergedInventoryDossierService {
|
||||
constructor(
|
||||
private readonly assets: AssetsService,
|
||||
private readonly activity: ActivityDossierService,
|
||||
private readonly merges: InventoryMergeService,
|
||||
private readonly functions: InventoryFunctionService,
|
||||
) {}
|
||||
@@ -43,7 +45,7 @@ export class MergedInventoryDossierService {
|
||||
// Los registros territoriales (Departamento, Área, Yacimiento) deben poder
|
||||
// abrir su Actividad sin depender del subsistema de merge.
|
||||
if (!MERGEABLE_DOSSIER_TYPES.has(requestedTypeCode)) {
|
||||
return await this.assets.dossier(requestedAssetId) as Record<string, unknown>;
|
||||
return await this.activity.dossier(requestedAssetId);
|
||||
}
|
||||
|
||||
const mergeStatus = await this.merges.status(requestedAssetId) as LooseRecord;
|
||||
@@ -56,7 +58,7 @@ export class MergedInventoryDossierService {
|
||||
.filter((value, index, all) => all.indexOf(value) === index);
|
||||
|
||||
const dossiers = await Promise.all(inventoryIds.map(async (assetId) => {
|
||||
const dossier = await this.assets.dossier(assetId) as LooseRecord;
|
||||
const dossier = await this.activity.dossier(assetId) as LooseRecord;
|
||||
const identity = dossier.asset as LooseRecord;
|
||||
const functionDossier = await this.functions.getForAsset(assetId).catch(() => null) as LooseRecord | null;
|
||||
return { assetId, identity, dossier, functionDossier };
|
||||
@@ -157,6 +159,9 @@ export class MergedInventoryDossierService {
|
||||
const reports = documents.filter((document) => document.documentType === 'TECHNICAL_REPORT');
|
||||
const openFindings = findings.filter((finding) => finding.status === 'OPEN').length;
|
||||
const closedFindings = findings.filter((finding) => finding.status === 'CLOSED').length;
|
||||
const warnings = dossiers.flatMap(({ assetId, dossier }) =>
|
||||
((dossier.warnings ?? []) as string[]).map((facet) => `${assetId}:${facet}`),
|
||||
);
|
||||
|
||||
return {
|
||||
asset: {
|
||||
@@ -206,6 +211,7 @@ export class MergedInventoryDossierService {
|
||||
media,
|
||||
versions,
|
||||
timeline: timeline.slice(0, 1000),
|
||||
warnings,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user