code: private Double fetchBuildDurationWithinThresholdRatio(Iterable<Build> builds, long thresholdInMillis) {
      int totalBuilds = 0, totalBelowThreshold = 0;
      for (Build build : builds) {
        if (!Constants.SUCCESS_STATUS.contains(build.getBuildStatus())) {
          continue;
        }
  
        totalBuilds++;
        if (build.getDuration() < thresholdInMillis) {
          totalBelowThreshold++;
        }
      }
      if (totalBuilds == 0) {
        return 0.0d;
      }
      return ((totalBelowThreshold * 100) / (double) totalBuilds);
    }
docs: Calculate builds that completed successfully within threshold time
  Only builds with status as Success, Unstable is included for calculation
  
  @param builds iterable builds
  @param thresholdInMillis threshold for build times in milliseconds
  @return percentage of builds within threshold