-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpblist.go
66 lines (54 loc) · 1.78 KB
/
pblist.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package kilonova
import (
"log/slog"
"time"
)
type ProblemList struct {
ID int `json:"id"`
CreatedAt time.Time `json:"created_at"`
AuthorID int `json:"author_id"`
Title string `json:"title"`
Description string `json:"description"`
List []int `json:"list"`
// NumProblems holds the number of problems including sublists
NumProblems int `json:"num_problems"`
SidebarHidable bool `json:"sidebar_hidable"`
FeaturedChecklist bool `json:"featured_checklist"`
// This is a separate type and not a ProblemList because it might
// not necessairly be a tree-like structure (ie. it might have cycles)
SubLists []*ShallowProblemList `json:"sublists"`
}
func (p *ProblemList) LogValue() slog.Value {
if p == nil {
return slog.Value{}
}
return slog.GroupValue(slog.Int("id", p.ID), slog.String("name", p.Title))
}
func (p *ProblemList) ProblemIDs() []int {
if p == nil {
return nil
}
return p.List
}
type ShallowProblemList struct {
ID int `json:"id"`
Title string `json:"title"`
AuthorID int `json:"author_id"`
SidebarHidable bool `json:"sidebar_hidable"`
FeaturedChecklist bool `json:"featured_checklist"`
// NumProblems holds the number of problems including sublists
NumProblems int `json:"num_problems"`
}
type ProblemListUpdate struct {
AuthorID *int `json:"author_id"`
Title *string `json:"title"`
Description *string `json:"description"`
SidebarHidable *bool `json:"sidebar_hidable"`
FeaturedChecklist *bool `json:"featured_checklist"`
}
type ProblemListFilter struct {
Root bool `json:"root"`
FeaturedChecklist *bool `json:"featured_checklist"`
// Note that results with ParentID include that parent as well, it should print out the entire tree
ParentID *int `json:"parent_id"`
}