Skip to content

Commit

Permalink
update edx log so it not adding duplicated data (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndduc01 authored Oct 7, 2024
1 parent 85e6682 commit 359705e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
import gov.cdc.dataingestion.validation.repository.model.ValidatedELRModel;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import static gov.cdc.dataingestion.constant.MessageType.HL7_ELR;

Expand Down Expand Up @@ -82,9 +84,14 @@ public MessageStatus getMessageStatus(String rawMessageID) {
List<EdxActivityLogModelView> edxActivityStatusList = iEdxActivityLogRepository.
getEdxActivityLogDetailsBySourceId(Long.valueOf(msgStatus.getNbsInfo().getNbsInterfaceId()));
if(!edxActivityStatusList.isEmpty()) {
Set<String> seenComments = new HashSet<>();
for(EdxActivityLogModelView edxActivityLogModel:edxActivityStatusList){
EdxActivityLogStatus edxActivityLogStatus = getEdxActivityLogStatus(edxActivityLogModel);
msgStatus.getNbsIngestionInfo().add(edxActivityLogStatus);
String logComment = edxActivityLogModel.getLogComment();
if (seenComments.add(logComment)) {
EdxActivityLogStatus edxActivityLogStatus = getEdxActivityLogStatus(edxActivityLogModel);
msgStatus.getNbsIngestionInfo().add(edxActivityLogStatus);
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

import gov.cdc.dataprocessing.repository.nbs.odse.model.log.EdxActivityDetailLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface EdxActivityDetailLogRepository extends JpaRepository<EdxActivityDetailLog, Long> {

@Query(value = "SELECT edx_activity_detail_log_uid FROM NBS_ODSE.dbo.EDX_activity_detail_log WHERE edx_activity_log_uid = :edxActivityLogUid AND log_comment = :logComment", nativeQuery = true)
List<Integer> findIdsByEdxActivityLogUidAndLogComment(@Param("edxActivityLogUid") Long edxActivityLogUid, @Param("logComment") String logComment);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ public EdxLogService(EdxActivityLogRepository edxActivityLogRepository,
@Override
public EdxActivityDetailLog saveEdxActivityDetailLog(EDXActivityDetailLogDto detailLogDto) {
EdxActivityDetailLog edxActivityDetailLog = new EdxActivityDetailLog(detailLogDto);
EdxActivityDetailLog edxActivityDetailLogResult = edxActivityDetailLogRepository.save(edxActivityDetailLog);
return edxActivityDetailLogResult;
var checkDetailLogList = edxActivityDetailLogRepository.findIdsByEdxActivityLogUidAndLogComment(edxActivityDetailLog.getEdxActivityLogUid(), edxActivityDetailLog.getLogComment());
if (checkDetailLogList.isEmpty()){
EdxActivityDetailLog edxActivityDetailLogResult = edxActivityDetailLogRepository.save(edxActivityDetailLog);
return edxActivityDetailLogResult;
}
return new EdxActivityDetailLog();
}
@Transactional()
public void saveEdxActivityLogs(EDXActivityLogDto edxActivityLogDto) {
Expand Down

0 comments on commit 359705e

Please sign in to comment.