-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.go
93 lines (83 loc) · 2.81 KB
/
models.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
86
87
88
89
90
91
92
93
package git
import (
"database/sql"
"time"
"github.com/bluekeyes/go-gitdiff/gitdiff"
)
// User is a db model for users.
type User struct {
ID int64 `db:"id"`
Pubkey string `db:"pubkey"`
Name string `db:"name"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
// Acl is a db model for access control.
type Acl struct {
ID int64 `db:"id"`
Pubkey sql.NullString `db:"pubkey"`
IpAddress sql.NullString `db:"ip_address"`
Permission string `db:"permission"`
CreatedAt time.Time `db:"created_at"`
}
// Repo is a container for patch requests.
type Repo struct {
ID int64 `db:"id"`
Name string `db:"name"`
UserID int64 `db:"user_id"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
// PatchRequest is a database model for patches submitted to a Repo.
type PatchRequest struct {
ID int64 `db:"id"`
UserID int64 `db:"user_id"`
RepoID int64 `db:"repo_id"`
Name string `db:"name"`
Text string `db:"text"`
Status string `db:"status"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
// only used for aggregate queries
LastUpdated string `db:"last_updated"`
}
type Patchset struct {
ID int64 `db:"id"`
UserID int64 `db:"user_id"`
PatchRequestID int64 `db:"patch_request_id"`
Review bool `db:"review"`
CreatedAt time.Time `db:"created_at"`
}
// Patch is a database model for a single entry in a patchset.
// This usually corresponds to a git commit.
type Patch struct {
ID int64 `db:"id"`
UserID int64 `db:"user_id"`
PatchsetID int64 `db:"patchset_id"`
AuthorName string `db:"author_name"`
AuthorEmail string `db:"author_email"`
AuthorDate time.Time `db:"author_date"`
Title string `db:"title"`
Body string `db:"body"`
BodyAppendix string `db:"body_appendix"`
CommitSha string `db:"commit_sha"`
ContentSha string `db:"content_sha"`
BaseCommitSha sql.NullString `db:"base_commit_sha"`
RawText string `db:"raw_text"`
CreatedAt time.Time `db:"created_at"`
Files []*gitdiff.File
}
func (p *Patch) CalcDiff() string {
return p.RawText
}
// EventLog is a event log for RSS or other notification systems.
type EventLog struct {
ID int64 `db:"id"`
UserID int64 `db:"user_id"`
RepoID sql.NullInt64 `db:"repo_id"`
PatchRequestID sql.NullInt64 `db:"patch_request_id"`
PatchsetID sql.NullInt64 `db:"patchset_id"`
Event string `db:"event"`
Data string `db:"data"`
CreatedAt time.Time `db:"created_at"`
}