Skip to content

Commit

Permalink
feat(graphql): implements basic task state retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Nov 29, 2022
1 parent f1e3340 commit 0939f70
Show file tree
Hide file tree
Showing 6 changed files with 504 additions and 66 deletions.
6 changes: 3 additions & 3 deletions app/nemeton/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import "time"

// nolint: funlen,lll
func bootstrapPhases() []Phase {
r100 := 100
r200 := 200
r500 := 500
r100 := uint64(100)
r200 := uint64(200)
r500 := uint64(500)
return []Phase{
{
Number: 1,
Expand Down
7 changes: 6 additions & 1 deletion app/nemeton/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Task struct {
Description string `bson:"description"`
StartDate time.Time `bson:"startDate"`
EndDate time.Time `bson:"endDate"`
Rewards *int `bson:"rewards,omitempty"`
Rewards *uint64 `bson:"rewards,omitempty"`
}

func (t Task) Started() bool {
Expand All @@ -30,3 +30,8 @@ func (t Task) Finished() bool {
func (t Task) WithSubmission() bool {
return t.Type == taskTypeSubmission
}

type TaskState struct {
Completed bool `bson:"completed"`
EarnedPoints uint64 `bson:"points"`
}
31 changes: 20 additions & 11 deletions app/nemeton/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import (
)

type Validator struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
Moniker string `bson:"moniker"`
Identity *string `bson:"identity,omitempty"`
Valoper types.ValAddress `bson:"valoper"`
Delegator types.AccAddress `bson:"delegator"`
Twitter *string `bson:"twitter,omitempty"`
Website *url.URL `bson:"website,omitempty"`
Discord string `bson:"discord"`
Country string `bson:"country"`
Status string `bson:"status"`
Points uint64 `bson:"points"`
ID primitive.ObjectID `bson:"_id,omitempty"`
Moniker string `bson:"moniker"`
Identity *string `bson:"identity,omitempty"`
Valoper types.ValAddress `bson:"valoper"`
Delegator types.AccAddress `bson:"delegator"`
Twitter *string `bson:"twitter,omitempty"`
Website *url.URL `bson:"website,omitempty"`
Discord string `bson:"discord"`
Country string `bson:"country"`
Status string `bson:"status"`
Points uint64 `bson:"points"`
Tasks map[int]map[string]TaskState `bson:"tasks"`
}

func (v *Validator) Cursor() *Cursor {
Expand All @@ -27,3 +28,11 @@ func (v *Validator) Cursor() *Cursor {
objectID: v.ID,
}
}

func (v *Validator) Task(phase int, id string) *TaskState {
if tasks, ok := v.Tasks[phase]; ok {
task := tasks[id]
return &task
}
return nil
}
Loading

0 comments on commit 0939f70

Please sign in to comment.