Skip to content

Commit 261cb81

Browse files
fix(brain): persist stageDetails so coverage fields reach the UI
recordStageDetails only mutated the in-memory status handle; updateProgress reloads from DB and dropped SCHEMA_SCAN coverage metrics. Write merged stageDetails to the live row so W2b coverage is visible on init-status. Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
1 parent b86f0d6 commit 261cb81

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

backend/src/main/java/com/dbaagent/service/scheduler/BrainInitStageExecutor.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,33 @@ private void closeActiveStage(ConnectionInitStatus status) {
714714
}
715715

716716
private void recordStageDetails(ConnectionInitStatus status, InitStage stage, Map<String, Object> details) {
717+
// Mutate the in-memory handle used by later markCompleted/history…
718+
if (status.getStageDetails() == null) {
719+
status.setStageDetails(new HashMap<>());
720+
}
717721
status.getStageDetails().put(stage.name(), new HashMap<>(details));
722+
723+
// …and persist onto the live row. updateProgress/updateStage reload from
724+
// the DB, so writing only the in-memory object used to leave stageDetails
725+
// permanently empty — which hid the W2b coverage fields from the UI.
726+
try {
727+
var current = initStatusRepo.findById(status.getConnectionId());
728+
if (current.isEmpty()) {
729+
return;
730+
}
731+
ConnectionInitStatus fresh = current.get();
732+
Map<String, Object> merged = fresh.getStageDetails() != null
733+
? new HashMap<>(fresh.getStageDetails())
734+
: new HashMap<>();
735+
merged.put(stage.name(), new HashMap<>(details));
736+
fresh.setStageDetails(merged);
737+
initStatusRepo.save(fresh);
738+
// Keep the caller’s handle in sync with what we just wrote.
739+
status.setStageDetails(merged);
740+
} catch (Exception e) {
741+
log.warn("Failed to persist stageDetails for {} / {}: {}",
742+
status.getConnectionId(), stage, e.getMessage());
743+
}
718744
}
719745

720746
private void broadcast(String connectionId, ConnectionInitStatus status) {

0 commit comments

Comments
 (0)