-
Notifications
You must be signed in to change notification settings - Fork 0
/
issue.go
85 lines (81 loc) · 2.03 KB
/
issue.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Issue holds the schema definition for the Issue entity.
type Issue struct {
ent.Schema
}
// Fields of the Issue.
func (Issue) Fields() []ent.Field {
return []ent.Field{
field.Int64("id"),
field.String("node_id"),
field.String("url").
Comment("URL for the issue"),
field.String("repository_url"),
field.String("labels_url"),
field.String("comments_url"),
field.String("events_url"),
field.String("html_url"),
field.Int64("number").
Comment("Number uniquely identifying the issue within its repository"),
field.String("state").
Comment("State of the issue; either 'open' or 'closed'"),
field.Enum("state_reason").
Optional().
Nillable().
Values("completed", "reopened", "not_planned"),
field.String("title").
Comment("Title of the issue"),
field.String("body").
Optional().
Nillable(),
field.Bool("locked"),
field.String("active_lock_reason").
Optional().
Nillable(),
// field.Int64("comments"), removed in favour of comments edge
field.Time("closed_at").
Optional().
Nillable(),
field.Time("created_at"),
field.Time("updated_at"),
field.Bool("draft"),
// TODO: unify with IssueComment
field.Enum("author_association").Values(
"COLLABORATOR",
"CONTRIBUTOR",
"FIRST_TIMER",
"FIRST_TIME_CONTRIBUTOR",
"MANNEQUIN",
"MEMBER",
"NONE",
"OWNER",
),
// TODO: better type
field.JSON("reactions", map[string]any{}),
}
}
// Edges of the Issue.
func (Issue) Edges() []ent.Edge {
// edge: labels
// edge: pull_request
// edge: milestone (#/components/schemas/nullable-milestone)
// edge: performed_via_github_app (#/components/schemas/nullable-integration)
return []ent.Edge{
edge.From("repository", Repository.Type).
Ref("issues").
Unique().
Required(),
edge.From("user", User.Type).
Ref("issues_created").
Unique(),
edge.To("assignees", User.Type),
edge.To("closed_by", User.Type).
Unique(),
edge.To("comments", IssueComment.Type),
}
}