package com.cloudhandson.vpdbackoffice.domain.schema;

import java.util.List;

public record SchemaPreflightView(
    String currentUser,
    String recommendedOrdsSchema,
    List<SchemaPreflightCheck> checks,
    String appDdlPreview,
    String sqlclScript
) {

  public long okCount() {
    return count("OK");
  }

  public long warnCount() {
    return count("WARN");
  }

  public long missingCount() {
    return count("MISSING");
  }

  public long errorCount() {
    return count("ERROR");
  }

  public boolean hasActionNeeded() {
    return warnCount() + missingCount() + errorCount() > 0;
  }

  private long count(String status) {
    return checks.stream()
        .filter(check -> status.equalsIgnoreCase(check.status()))
        .count();
  }
}
