summaryrefslogtreecommitdiff
path: root/scoring.go
diff options
context:
space:
mode:
authorflu0r1ne <flu0r1ne@flu0r1ne.net>2021-09-05 20:37:19 -0500
committerflu0r1ne <flu0r1ne@flu0r1ne.net>2021-09-05 20:37:19 -0500
commitf5b60238e05b124eb40f805eb4a0bbfc0b043da5 (patch)
treef461bff108f5ddafc4078aa7394d7bf2a6309cc9 /scoring.go
parent8f22bd4f5b4eb6996c524bcb6948d36cef0ac822 (diff)
parentfd66fb134967067ed7e1c3182325f646b73c730b (diff)
downloaddeb-planr-f5b60238e05b124eb40f805eb4a0bbfc0b043da5.tar.xz
deb-planr-f5b60238e05b124eb40f805eb4a0bbfc0b043da5.zip
Merge branch 'upstream' into ppa
Merge v0.1.0
Diffstat (limited to 'scoring.go')
-rw-r--r--scoring.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/scoring.go b/scoring.go
new file mode 100644
index 0000000..675058a
--- /dev/null
+++ b/scoring.go
@@ -0,0 +1,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
+}