RED-8711 - Filter out entity log entries that have no positions and show a toast message in dev mode
This commit is contained in:
parent
55f62e7197
commit
9d6e0f35cf
@ -191,22 +191,6 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
|
||||
}
|
||||
|
||||
const canBeMappedToASuperType = !!SuperTypeMapper[entry.entryType][entry.state](entry);
|
||||
if (!canBeMappedToASuperType && this.#isIqserDevMode) {
|
||||
this.#logger.error(
|
||||
`[ENTITY_LOG] Entity ${entry.value} (${entry.entryType}, ${entry.state}) cannot be mapped to a super type!`,
|
||||
entry,
|
||||
);
|
||||
this.#toaster.rawError(
|
||||
`Skipping entity ${entry.value} (${entry.entryType}, ${entry.state}). It has unexpected state.
|
||||
Check console for details.`,
|
||||
{
|
||||
timeOut: 10000,
|
||||
easing: 'ease-in-out',
|
||||
easeTime: 500,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if (!canBeMappedToASuperType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { GenericService } from '@iqser/common-ui';
|
||||
import { IEntityLog, ISectionGrid } from '@red/domain';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { GenericService, isIqserDevMode, Toaster } from '@iqser/common-ui';
|
||||
import { EntryStates, IEntityLog, IEntityLogEntry, ISectionGrid } from '@red/domain';
|
||||
import { firstValueFrom, of } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@ -9,11 +9,14 @@ import { catchError } from 'rxjs/operators';
|
||||
})
|
||||
export class EntityLogService extends GenericService<unknown> {
|
||||
protected readonly _defaultModelPath = '';
|
||||
readonly #isIqserDevMode = isIqserDevMode();
|
||||
readonly #toaster = inject(Toaster);
|
||||
|
||||
async getEntityLog(dossierId: string, fileId: string) {
|
||||
const queryParams = [{ key: 'includeUnprocessed', value: true }];
|
||||
const entityLog$ = this._getOne<IEntityLog>([dossierId, fileId], 'entityLog', queryParams);
|
||||
const entityLog = await firstValueFrom(entityLog$.pipe(catchError(() => of({} as IEntityLog))));
|
||||
entityLog.entityLogEntry = this.#filterInvalidEntries(entityLog.entityLogEntry);
|
||||
entityLog.entityLogEntry.sort((a, b) => a.positions[0].pageNumber - b.positions[0].pageNumber);
|
||||
return entityLog;
|
||||
}
|
||||
@ -21,4 +24,15 @@ export class EntityLogService extends GenericService<unknown> {
|
||||
getSectionGrid(dossierId: string, fileId: string) {
|
||||
return this._getOne<ISectionGrid>([dossierId, fileId], 'sectionGrid');
|
||||
}
|
||||
|
||||
#filterInvalidEntries(entityLogEntry: IEntityLogEntry[]) {
|
||||
return entityLogEntry.filter(entry => {
|
||||
const hasPositions = !!entry.positions?.length;
|
||||
const isRemoved = entry.state === EntryStates.REMOVED;
|
||||
if (!hasPositions) {
|
||||
this.#toaster.devInfo(`Entry ${entry.id} was skipped because it has no position`);
|
||||
}
|
||||
return hasPositions && !isRemoved;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit fa80d067bd4a74cec187c51e62813090fd1d40f2
|
||||
Subproject commit 3b6406517a450dc1da1cf300f34261f50fb45e14
|
||||
Loading…
x
Reference in New Issue
Block a user