evaluation.gno
0.81 Kb ยท 40 lines
1package evaluation
2
3import (
4 "gno.land/p/nt/avl"
5 "gno.land/p/nt/ufmt"
6)
7
8type Evaluation struct {
9 contributions avl.Tree
10 pullrequests avl.Tree
11}
12
13type Evaluator interface {
14 Evaluate() Points
15}
16
17func NewEvalutaion() *Evaluation {
18 e := &Evaluation{
19 contributions: avl.Tree{},
20 pullrequests: avl.Tree{},
21 }
22 return e
23}
24
25func (e *Evaluation) AddContribution(pr *PullRequest, contributor address) (int, bool) {
26 id := pr.Id()
27 e.pullrequests.Set(ufmt.Sprintf("%d", id), pr)
28 c := NewContribution(id, contributor)
29 e.contributions.Set(ufmt.Sprintf("%d", id), c)
30 return id, true
31}
32
33func (e *Evaluation) UpdateContribution(id int, status string) bool {
34 c, exists := e.contributions.Get(ufmt.Sprintf("%d", id))
35 if exists {
36 contribtution := c.(*Contribution)
37 return contribtution.UpdateStatus(status)
38 }
39 return false
40}