smart auto reanalyse
This commit is contained in:
parent
c4f1ced578
commit
5b25967a25
@ -130,4 +130,10 @@ export class FileStatusWrapper {
|
||||
get canApprove() {
|
||||
return this.status === 'UNDER_REVIEW' || this.status === 'UNDER_APPROVAL';
|
||||
}
|
||||
|
||||
get newestDate() {
|
||||
const uploadedDate = new Date(this.fileStatus.lastUploaded);
|
||||
const updatedDate = new Date(this.fileStatus.lastUpdated);
|
||||
return updatedDate && updatedDate.getTime() > uploadedDate.getTime() ? updatedDate : uploadedDate;
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,13 +184,38 @@ export class AppStateService {
|
||||
}
|
||||
|
||||
private _automaticallyReanalyseErrorFiles(project: ProjectWrapper) {
|
||||
const now = new Date().getTime();
|
||||
project.files.forEach((file) => {
|
||||
if (file.status === 'ERROR') {
|
||||
this._reanalysisControllerService.reanalyzeFile(project.projectId, file.fileId).subscribe(() => {});
|
||||
console.log('Auto-Reanalyse file because of error');
|
||||
this._reanalyseFileInCurrentSessionIfNeeded(project, file);
|
||||
}
|
||||
if (file.status === 'PROCESSING') {
|
||||
const delta = now - file.newestDate.getTime();
|
||||
if (delta > 1000 * 60 * 5) {
|
||||
console.log('Auto-Reanalyse file because of timeout');
|
||||
this._reanalyseFileInCurrentSessionIfNeeded(project, file);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private _reanalyseFileInCurrentSessionIfNeeded(project: ProjectWrapper, file: FileStatusWrapper) {
|
||||
const result = sessionStorage.getItem('FILE_' + file.fileId);
|
||||
if (!result) {
|
||||
this._reanalysisControllerService.reanalyzeFile(project.projectId, file.fileId).subscribe(() => {});
|
||||
sessionStorage.setItem('FILE_' + file.fileId, `${new Date().getTime()}`);
|
||||
} else {
|
||||
const now = new Date().getTime();
|
||||
const lastAttempt = new Date(result).getTime();
|
||||
const delta = now - lastAttempt;
|
||||
if (delta > 1000 * 60 * 5) {
|
||||
this._reanalysisControllerService.reanalyzeFile(project.projectId, file.fileId).subscribe(() => {});
|
||||
sessionStorage.setItem('FILE_' + file.fileId, `${new Date().getTime()}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getFiles(project?: ProjectWrapper) {
|
||||
if (!project) {
|
||||
project = this.activeProject;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user