Count visible incidents and high-severity incidents from a small queue.

incident-queue-report Counting with a loop makes the threshold and the visible queue size explicit.

Incident Queue Reliability Report

minSeverity
IncidentQueueReliabilityReport.scala
Replay: real traced execution (multi-file project)
object Main {
  def main(args: Array[String]): Unit = {
    val minSeverity = 2
    val severities = List(1, 2, 3, 3)
    var visible = 0
    var high = 0

    for (severity <- severities) {
      if (severity >= minSeverity) {
        visible = visible + 1
      }
      if (severity >= 3) {
        high = high + 1
      }
    }

    println("min=" + minSeverity)
    println("visible=" + visible)
    println("high=" + high)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val minSeverity = 1
    val severities = List(1, 2, 3, 3)
    var visible = 0
    var high = 0

    for (severity <- severities) {
      if (severity >= minSeverity) {
        visible = visible + 1
      }
      if (severity >= 3) {
        high = high + 1
      }
    }

    println("min=" + minSeverity)
    println("visible=" + visible)
    println("high=" + high)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val minSeverity = 3
    val severities = List(1, 2, 3, 3)
    var visible = 0
    var high = 0

    for (severity <- severities) {
      if (severity >= minSeverity) {
        visible = visible + 1
      }
      if (severity >= 3) {
        high = high + 1
      }
    }

    println("min=" + minSeverity)
    println("visible=" + visible)
    println("high=" + high)
  }
}
  1. minSeverity ← 2, severities ← List(1, 2, 3, 3), visible ← 0, high ← 0

    1object Main {2  def main(args: Array[String]): Unit = {3    val minSeverity→ 2 = 2 //@minSeverity=1, 34    val severities→ List(1, 2, 3, 3) = List(1, 2, 3, 3)5    var visible→ 0 = 06    var high→ 0 = 078    for (severity <- severities) {
  2. for (severity <- severities)

    pass 1 of 4
    8for (severity1 <- severitiesList(1, 2, 3, 3)) {9  if (severity >= minSeverity) {
    All 4 passes — pass 1 is the card above
    passseverityhigh
    11
    22
    330 1
    431 2
  3. visible ← 1

    pass 1 of 3
    8for (severity <- severities) {9  if (severity2 >= minSeverity2) {10    visible→ 1 = visible + 111  }12  if (severity >= 3) {
    All 3 passes — pass 1 is the card above
    passseverityvisiblehigh
    120 1
    231 20 1
    332 31 2
  4. high ← 1

    pass 1 of 2
    11  }12  if (severity3 >= 3) {13    high→ 1 = high + 114  }15}
  5. high ← 2

    pass 2 of 2
    11  }12  if (severity3 >= 3) {13    high→ 2 = high + 114  }15}
  6. println("min=" + minSeverity)

    17    println("min=" + minSeverity2)18    println("visible=" + visible3)19    println("high=" + high2)20  }21}
    outputmin=2
    visible=3
    high=2
  1. minSeverity ← 1, severities ← List(1, 2, 3, 3), visible ← 0, high ← 0

    1object Main {2  def main(args: Array[String]): Unit = {3    val minSeverity→ 1 = 14    val severities→ List(1, 2, 3, 3) = List(1, 2, 3, 3)5    var visible→ 0 = 06    var high→ 0 = 078    for (severity <- severities) {
  2. for (severity <- severities)

    pass 1 of 4
    8for (severity1 <- severitiesList(1, 2, 3, 3)) {9  if (severity >= minSeverity) {
    All 4 passes — pass 1 is the card above
    passseverityhigh
    11
    22
    330 1
    431 2
  3. visible ← 1

    pass 1 of 4
    8for (severity <- severities) {9  if (severity1 >= minSeverity1) {10    visible→ 1 = visible + 111  }12  if (severity >= 3) {
    All 4 passes — pass 1 is the card above
    passseverityvisiblehigh
    110 1
    221 2
    332 30 1
    433 41 2
  4. high ← 1

    pass 1 of 2
    11  }12  if (severity3 >= 3) {13    high→ 1 = high + 114  }15}
  5. high ← 2

    pass 2 of 2
    11  }12  if (severity3 >= 3) {13    high→ 2 = high + 114  }15}
  6. println("min=" + minSeverity)

    17    println("min=" + minSeverity1)18    println("visible=" + visible4)19    println("high=" + high2)20  }21}
    outputmin=1
    visible=4
    high=2
  1. minSeverity ← 3, severities ← List(1, 2, 3, 3), visible ← 0, high ← 0

    1object Main {2  def main(args: Array[String]): Unit = {3    val minSeverity→ 3 = 34    val severities→ List(1, 2, 3, 3) = List(1, 2, 3, 3)5    var visible→ 0 = 06    var high→ 0 = 078    for (severity <- severities) {
  2. for (severity <- severities)

    pass 1 of 4
    8for (severity1 <- severitiesList(1, 2, 3, 3)) {9  if (severity >= minSeverity) {
    All 4 passes — pass 1 is the card above
    passseverityminSeverityvisiblehigh
    11
    22
    3330 10 1
    4331 21 2
  3. visible ← 1

    pass 1 of 2
    8for (severity <- severities) {9  if (severity3 >= minSeverity3) {10    visible→ 1 = visible + 111  }12  if (severity >= 3) {
  4. high ← 1

    pass 1 of 2
    11  }12  if (severity3 >= 3) {13    high→ 1 = high + 114  }15}
  5. visible ← 2

    pass 2 of 2
    8for (severity <- severities) {9  if (severity3 >= minSeverity3) {10    visible→ 2 = visible + 111  }12  if (severity >= 3) {
  6. high ← 2

    pass 2 of 2
    11  }12  if (severity3 >= 3) {13    high→ 2 = high + 114  }15}
  7. println("min=" + minSeverity)

    17    println("min=" + minSeverity3)18    println("visible=" + visible2)19    println("high=" + high2)20  }21}
    outputmin=3
    visible=2
    high=2