RED-3219: Fixed to many and unneeded update index calls
This commit is contained in:
parent
b30596e8b4
commit
723960b29f
@ -51,13 +51,13 @@ public class FileStatusPersistenceService {
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateWorkflowStatus(String fileId, int numberOfPages, long dictionaryVersion, long rulesVersion,
|
||||
long legalBasisVersion, long duration, long dossierDictionaryVersion,
|
||||
int analysisVersion, int analysisNumber) {
|
||||
public void updateProcessingStatus(String fileId, int numberOfPages, long dictionaryVersion, long rulesVersion,
|
||||
long legalBasisVersion, long duration, long dossierDictionaryVersion,
|
||||
int analysisVersion, int analysisNumber) {
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.updateWorkflowStatus(fileId, numberOfPages, ProcessingStatus.PROCESSED,
|
||||
fileRepository.updateProcessingStatus(fileId, numberOfPages, ProcessingStatus.PROCESSED,
|
||||
dictionaryVersion, rulesVersion, legalBasisVersion, duration, dossierDictionaryVersion,
|
||||
analysisVersion, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), analysisNumber);
|
||||
|
||||
@ -2,7 +2,6 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.DossierChange;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.ProcessingStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
@ -41,9 +40,9 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
"f.analysisVersion = :analysisVersion, f.numberOfAnalyses = :analysisNumber, f.lastUpdated = :lastUpdated, " +
|
||||
"f.lastProcessed = :lastProcessed " +
|
||||
"where f.id = :fileId")
|
||||
void updateWorkflowStatus(String fileId, int numberOfPages, ProcessingStatus processingStatus, long dictionaryVersion,
|
||||
long rulesVersion, long legalBasisVersion, long analysisDuration, long dossierDictionaryVersion,
|
||||
int analysisVersion, OffsetDateTime lastUpdated, OffsetDateTime lastProcessed, int analysisNumber);
|
||||
void updateProcessingStatus(String fileId, int numberOfPages, ProcessingStatus processingStatus, long dictionaryVersion,
|
||||
long rulesVersion, long legalBasisVersion, long analysisDuration, long dossierDictionaryVersion,
|
||||
int analysisVersion, OffsetDateTime lastUpdated, OffsetDateTime lastProcessed, int analysisNumber);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.workflowStatus = :workflowStatus, f.lastUpdated = :lastUpdated, f.approvalDate = :approvalDate " +
|
||||
|
||||
@ -9,6 +9,8 @@ import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.do
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.ProcessingStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.StatusResource;
|
||||
import com.iqser.red.service.search.v1.model.IndexMessageType;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -30,6 +32,7 @@ public class FileStatusController implements StatusResource {
|
||||
private final ExcludeFromAnalysisService excludeFromAnalysis;
|
||||
private final AnalysisFlagsCalculationService analysisFlagsCalculationService;
|
||||
private final ReanalysisRequiredStatusService reanalysisRequiredStatusService;
|
||||
private final IndexingService indexingService;
|
||||
|
||||
@Override
|
||||
public List<FileModel> getAllStatuses() {
|
||||
@ -85,6 +88,7 @@ public class FileStatusController implements StatusResource {
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestParam(value = ASSIGNEE_ID_REQUEST_PARAM, required = false) String assigneeId) {
|
||||
fileStatusService.setAssignee(dossierId, fileId, assigneeId);
|
||||
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
|
||||
}
|
||||
|
||||
|
||||
@ -99,8 +103,9 @@ public class FileStatusController implements StatusResource {
|
||||
assignee = userId;
|
||||
fileStatusService.setAssignee(dossierId, fileId, assignee);
|
||||
}
|
||||
fileStatusService.setStatusSuccessful(dossierId, fileId, assignee != null ? WorkflowStatus.UNDER_REVIEW : WorkflowStatus.NEW);
|
||||
fileStatusService.setStatusSuccessful(fileId, assignee != null ? WorkflowStatus.UNDER_REVIEW : WorkflowStatus.NEW);
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
|
||||
}
|
||||
|
||||
public void setStatusUnderApproval(@PathVariable(DOSSIER_ID_PARAM) String dossierId,
|
||||
@ -114,8 +119,9 @@ public class FileStatusController implements StatusResource {
|
||||
|
||||
}
|
||||
fileStatusService.setAssignee(dossierId, fileId, approverId);
|
||||
fileStatusService.setStatusSuccessful(dossierId, fileId, assignee != null ? WorkflowStatus.UNDER_APPROVAL : WorkflowStatus.NEW);
|
||||
fileStatusService.setStatusSuccessful(fileId, assignee != null ? WorkflowStatus.UNDER_APPROVAL : WorkflowStatus.NEW);
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
|
||||
}
|
||||
|
||||
public void setStatusApproved(@PathVariable(DOSSIER_ID_PARAM) String dossierId,
|
||||
@ -132,6 +138,7 @@ public class FileStatusController implements StatusResource {
|
||||
}
|
||||
fileStatusService.setAssignee(dossierId, fileId, assignee);
|
||||
fileStatusService.setApprovalStatusSuccessful(dossierId, fileId, WorkflowStatus.APPROVED);
|
||||
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ public class FileStatusProcessingUpdateService {
|
||||
retryTemplate.execute(retryContext -> {
|
||||
log.info("Analysis Successful for dossier {} and file {}, Attempt to update status: {}", dossierId, fileId, retryContext
|
||||
.getRetryCount());
|
||||
fileStatusService.setStatusSuccessful(dossierId, fileId, analyzeResult);
|
||||
fileStatusService.setStatusSuccessful(fileId, analyzeResult);
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
@ -51,7 +51,6 @@ public class FileStatusService {
|
||||
private final AddRedactionPersistenceService addRedactionPersistenceService;
|
||||
private final ResizeRedactionPersistenceService resizeRedactionPersistenceService;
|
||||
private final FileManagementServiceSettings settings;
|
||||
private final IndexingService indexingService;
|
||||
|
||||
|
||||
public List<FileEntity> getActiveFiles(String dossierId) {
|
||||
@ -96,28 +95,25 @@ public class FileStatusService {
|
||||
}
|
||||
|
||||
|
||||
public void setStatusSuccessful(String dossierId, String fileId, AnalyzeResult analyzeResult) {
|
||||
public void setStatusSuccessful(String fileId, AnalyzeResult analyzeResult) {
|
||||
|
||||
fileStatusPersistenceService.updateWorkflowStatus(fileId, analyzeResult.getNumberOfPages(),
|
||||
fileStatusPersistenceService.updateProcessingStatus(fileId, analyzeResult.getNumberOfPages(),
|
||||
analyzeResult.getDictionaryVersion(), analyzeResult.getRulesVersion(),
|
||||
analyzeResult.getLegalBasisVersion(), analyzeResult.getDuration(),
|
||||
analyzeResult.getDossierDictionaryVersion(), analyzeResult.getAnalysisVersion(),
|
||||
analyzeResult.getAnalysisNumber());
|
||||
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
|
||||
}
|
||||
|
||||
|
||||
public void setStatusSuccessful(String dossierId, String fileId, WorkflowStatus workflowStatus) {
|
||||
public void setStatusSuccessful(String fileId, WorkflowStatus workflowStatus) {
|
||||
|
||||
fileStatusPersistenceService.updateWorkflowStatus(fileId, workflowStatus, false);
|
||||
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
|
||||
}
|
||||
|
||||
|
||||
public void setApprovalStatusSuccessful(String dossierId, String fileId, WorkflowStatus workflowStatus) {
|
||||
|
||||
fileStatusPersistenceService.updateWorkflowStatus(fileId, workflowStatus, true);
|
||||
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
|
||||
}
|
||||
|
||||
|
||||
@ -236,7 +232,6 @@ public class FileStatusService {
|
||||
}
|
||||
|
||||
fileStatusPersistenceService.setAssignee(fileId, assignee, lastReviewer, lastApprover);
|
||||
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user