summaryrefslogtreecommitdiff
path: root/scoring.go
blob: 675058a625a148c3e419097d133eb71617bae4d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package planr

type Scoring struct {
  EarnedPoints float64
  TotalPoints  float64
  Passed       int
  Total        int
}

func Score(trs []TestResult) Scoring {
  score := Scoring {}

  for _, tr := range trs {
    cfg := tr.Tc.Config
    points := 0.0

    if cfg.Points != nil {
      points = float64(*cfg.Points)
    }

    score.TotalPoints += points
    if tr.Status == PASSING {
      score.EarnedPoints += points
      score.Passed++
    }

    score.Total += 1
  }

  return score
}