diff --git a/datanode/src/main/java/com/odysseusinc/arachne/datanode/model/analysis/Analysis.java b/datanode/src/main/java/com/odysseusinc/arachne/datanode/model/analysis/Analysis.java index 62f3de6b..3d6dc2b3 100644 --- a/datanode/src/main/java/com/odysseusinc/arachne/datanode/model/analysis/Analysis.java +++ b/datanode/src/main/java/com/odysseusinc/arachne/datanode/model/analysis/Analysis.java @@ -148,6 +148,10 @@ public class Analysis { @Convert(converter = StringMapConverter.class) private Map parameters; + public AnalysisState getState() { + return Optional.ofNullable(state).orElse(AnalysisState.UNKNOWN); + } + public String getStage() { return Optional.ofNullable(currentState).map(AnalysisStateEntry::getStage).orElse(null); } diff --git a/datanode/src/main/java/com/odysseusinc/arachne/datanode/service/AnalysisService.java b/datanode/src/main/java/com/odysseusinc/arachne/datanode/service/AnalysisService.java index 40dd444c..e1d1d8f2 100644 --- a/datanode/src/main/java/com/odysseusinc/arachne/datanode/service/AnalysisService.java +++ b/datanode/src/main/java/com/odysseusinc/arachne/datanode/service/AnalysisService.java @@ -220,6 +220,7 @@ public List getIncompleteIds() { Join state = root.join(Analysis_.currentState, JoinType.LEFT); javax.persistence.criteria.Path stage = state.get(AnalysisStateEntry_.stage); return q.where( + cb.isNull(root.get(Analysis_.error)), cb.or(stage.isNull(), stage.in(Stage.EXECUTE, Stage.INITIALIZE, Stage.ABORT)) ); }).getResultStream().map(Analysis::getId).collect(Collectors.toList()); diff --git a/datanode/src/main/resources/db/migration/V20241210000004__update_stage_and_error.sql b/datanode/src/main/resources/db/migration/V20241210000004__update_stage_and_error.sql new file mode 100644 index 00000000..69cb9dbe --- /dev/null +++ b/datanode/src/main/resources/db/migration/V20241210000004__update_stage_and_error.sql @@ -0,0 +1,4 @@ +UPDATE analysis_state_journal SET + stage = analyses.stage, + error = analyses.error +FROM analyses WHERE analyses.current_state_id = analyses.id;