Browse Source

models: skip JSON for fields skipped by XORM

Reduce output JSON size by backup command
pull/5260/merge
Unknwon 7 years ago
parent
commit
53c8e4263b
No known key found for this signature in database
GPG Key ID: 7A02C406FAC875A2
  1. 4
      models/action.go
  2. 2
      models/admin.go
  3. 2
      models/attachment.go
  4. 14
      models/comment.go
  5. 26
      models/issue.go
  6. 4
      models/issue_label.go
  7. 6
      models/login_source.go
  8. 12
      models/milestone.go
  9. 8
      models/mirror.go
  10. 4
      models/org_team.go
  11. 10
      models/pull.go
  12. 10
      models/release.go
  13. 20
      models/repo.go
  14. 18
      models/ssh_key.go
  15. 8
      models/token.go
  16. 2
      models/two_factor.go
  17. 14
      models/user.go
  18. 2
      models/user_mail.go
  19. 14
      models/webhook.go

4
models/action.go

@ -80,14 +80,14 @@ type Action struct {
OpType ActionType
ActUserID int64 // Doer user ID
ActUserName string // Doer user name
ActAvatar string `xorm:"-"`
ActAvatar string `xorm:"-" json:"-"`
RepoID int64 `xorm:"INDEX"`
RepoUserName string
RepoName string
RefName string
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
Content string `xorm:"TEXT"`
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
}

2
models/admin.go

@ -30,7 +30,7 @@ type Notice struct {
ID int64
Type NoticeType
Description string `xorm:"TEXT"`
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
}

2
models/attachment.go

@ -27,7 +27,7 @@ type Attachment struct {
ReleaseID int64 `xorm:"INDEX"`
Name string
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
}

14
models/comment.go

@ -52,26 +52,26 @@ type Comment struct {
ID int64
Type CommentType
PosterID int64
Poster *User `xorm:"-"`
Poster *User `xorm:"-" json:"-"`
IssueID int64 `xorm:"INDEX"`
Issue *Issue `xorm:"-"`
Issue *Issue `xorm:"-" json:"-"`
CommitID int64
Line int64
Content string `xorm:"TEXT"`
RenderedContent string `xorm:"-"`
RenderedContent string `xorm:"-" json:"-"`
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
Updated time.Time `xorm:"-"`
Updated time.Time `xorm:"-" json:"-"`
UpdatedUnix int64
// Reference issue in commit message
CommitSHA string `xorm:"VARCHAR(40)"`
Attachments []*Attachment `xorm:"-"`
Attachments []*Attachment `xorm:"-" json:"-"`
// For view issue page.
ShowTag CommentTag `xorm:"-"`
ShowTag CommentTag `xorm:"-" json:"-"`
}
func (c *Comment) BeforeInsert() {

26
models/issue.go

@ -28,34 +28,34 @@ var (
type Issue struct {
ID int64
RepoID int64 `xorm:"INDEX UNIQUE(repo_index)"`
Repo *Repository `xorm:"-"`
Repo *Repository `xorm:"-" json:"-"`
Index int64 `xorm:"UNIQUE(repo_index)"` // Index in one repository.
PosterID int64
Poster *User `xorm:"-"`
Poster *User `xorm:"-" json:"-"`
Title string `xorm:"name"`
Content string `xorm:"TEXT"`
RenderedContent string `xorm:"-"`
Labels []*Label `xorm:"-"`
RenderedContent string `xorm:"-" json:"-"`
Labels []*Label `xorm:"-" json:"-"`
MilestoneID int64
Milestone *Milestone `xorm:"-"`
Milestone *Milestone `xorm:"-" json:"-"`
Priority int
AssigneeID int64
Assignee *User `xorm:"-"`
Assignee *User `xorm:"-" json:"-"`
IsClosed bool
IsRead bool `xorm:"-"`
IsRead bool `xorm:"-" json:"-"`
IsPull bool // Indicates whether is a pull request or not.
PullRequest *PullRequest `xorm:"-"`
PullRequest *PullRequest `xorm:"-" json:"-"`
NumComments int
Deadline time.Time `xorm:"-"`
Deadline time.Time `xorm:"-" json:"-"`
DeadlineUnix int64
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
Updated time.Time `xorm:"-"`
Updated time.Time `xorm:"-" json:"-"`
UpdatedUnix int64
Attachments []*Attachment `xorm:"-"`
Comments []*Comment `xorm:"-"`
Attachments []*Attachment `xorm:"-" json:"-"`
Comments []*Comment `xorm:"-" json:"-"`
}
func (issue *Issue) BeforeInsert() {

4
models/issue_label.go

@ -60,8 +60,8 @@ type Label struct {
Color string `xorm:"VARCHAR(7)"`
NumIssues int
NumClosedIssues int
NumOpenIssues int `xorm:"-"`
IsChecked bool `xorm:"-"`
NumOpenIssues int `xorm:"-" json:"-"`
IsChecked bool `xorm:"-" json:"-"`
}
func (label *Label) APIFormat() *api.Label {

6
models/login_source.go

@ -135,12 +135,12 @@ type LoginSource struct {
IsActived bool `xorm:"NOT NULL DEFAULT false"`
Cfg core.Conversion `xorm:"TEXT"`
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
Updated time.Time `xorm:"-"`
Updated time.Time `xorm:"-" json:"-"`
UpdatedUnix int64
LocalFile *AuthSourceFile `xorm:"-"`
LocalFile *AuthSourceFile `xorm:"-" json:"-"`
}
func (s *LoginSource) BeforeInsert() {

12
models/milestone.go

@ -22,18 +22,18 @@ type Milestone struct {
RepoID int64 `xorm:"INDEX"`
Name string
Content string `xorm:"TEXT"`
RenderedContent string `xorm:"-"`
RenderedContent string `xorm:"-" json:"-"`
IsClosed bool
NumIssues int
NumClosedIssues int
NumOpenIssues int `xorm:"-"`
NumOpenIssues int `xorm:"-" json:"-"`
Completeness int // Percentage(1-100).
IsOverDue bool `xorm:"-"`
IsOverDue bool `xorm:"-" json:"-"`
DeadlineString string `xorm:"-"`
Deadline time.Time `xorm:"-"`
DeadlineString string `xorm:"-" json:"-"`
Deadline time.Time `xorm:"-" json:"-"`
DeadlineUnix int64
ClosedDate time.Time `xorm:"-"`
ClosedDate time.Time `xorm:"-" json:"-"`
ClosedDateUnix int64
}

8
models/mirror.go

@ -29,17 +29,17 @@ var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)
type Mirror struct {
ID int64
RepoID int64
Repo *Repository `xorm:"-"`
Repo *Repository `xorm:"-" json:"-"`
Interval int // Hour.
EnablePrune bool `xorm:"NOT NULL DEFAULT true"`
// Last and next sync time of Git data from upstream
LastSync time.Time `xorm:"-"`
LastSync time.Time `xorm:"-" json:"-"`
LastSyncUnix int64 `xorm:"updated_unix"`
NextSync time.Time `xorm:"-"`
NextSync time.Time `xorm:"-" json:"-"`
NextSyncUnix int64 `xorm:"next_update_unix"`
address string `xorm:"-"`
address string `xorm:"-" json:"-"`
}
func (m *Mirror) BeforeInsert() {

4
models/org_team.go

@ -22,8 +22,8 @@ type Team struct {
Name string
Description string
Authorize AccessMode
Repos []*Repository `xorm:"-"`
Members []*User `xorm:"-"`
Repos []*Repository `xorm:"-" json:"-"`
Members []*User `xorm:"-" json:"-"`
NumRepos int
NumMembers int
}

10
models/pull.go

@ -48,13 +48,13 @@ type PullRequest struct {
Status PullRequestStatus
IssueID int64 `xorm:"INDEX"`
Issue *Issue `xorm:"-"`
Issue *Issue `xorm:"-" json:"-"`
Index int64
HeadRepoID int64
HeadRepo *Repository `xorm:"-"`
HeadRepo *Repository `xorm:"-" json:"-"`
BaseRepoID int64
BaseRepo *Repository `xorm:"-"`
BaseRepo *Repository `xorm:"-" json:"-"`
HeadUserName string
HeadBranch string
BaseBranch string
@ -63,8 +63,8 @@ type PullRequest struct {
HasMerged bool
MergedCommitID string `xorm:"VARCHAR(40)"`
MergerID int64
Merger *User `xorm:"-"`
Merged time.Time `xorm:"-"`
Merger *User `xorm:"-" json:"-"`
Merged time.Time `xorm:"-" json:"-"`
MergedUnix int64
}

10
models/release.go

@ -24,24 +24,24 @@ import (
type Release struct {
ID int64
RepoID int64
Repo *Repository `xorm:"-"`
Repo *Repository `xorm:"-" json:"-"`
PublisherID int64
Publisher *User `xorm:"-"`
Publisher *User `xorm:"-" json:"-"`
TagName string
LowerTagName string
Target string
Title string
Sha1 string `xorm:"VARCHAR(40)"`
NumCommits int64
NumCommitsBehind int64 `xorm:"-"`
NumCommitsBehind int64 `xorm:"-" json:"-"`
Note string `xorm:"TEXT"`
IsDraft bool `xorm:"NOT NULL DEFAULT false"`
IsPrerelease bool
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
Attachments []*Attachment `xorm:"-"`
Attachments []*Attachment `xorm:"-" json:"-"`
}
func (r *Release) BeforeInsert() {

20
models/repo.go

@ -143,7 +143,7 @@ func NewRepoContext() {
type Repository struct {
ID int64
OwnerID int64 `xorm:"UNIQUE(s)"`
Owner *User `xorm:"-"`
Owner *User `xorm:"-" json:"-"`
LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"`
Name string `xorm:"INDEX NOT NULL"`
Description string
@ -156,20 +156,20 @@ type Repository struct {
NumForks int
NumIssues int
NumClosedIssues int
NumOpenIssues int `xorm:"-"`
NumOpenIssues int `xorm:"-" json:"-"`
NumPulls int
NumClosedPulls int
NumOpenPulls int `xorm:"-"`
NumOpenPulls int `xorm:"-" json:"-"`
NumMilestones int `xorm:"NOT NULL DEFAULT 0"`
NumClosedMilestones int `xorm:"NOT NULL DEFAULT 0"`
NumOpenMilestones int `xorm:"-"`
NumTags int `xorm:"-"`
NumOpenMilestones int `xorm:"-" json:"-"`
NumTags int `xorm:"-" json:"-"`
IsPrivate bool
IsBare bool
IsMirror bool
*Mirror `xorm:"-"`
*Mirror `xorm:"-" json:"-"`
// Advanced settings
EnableWiki bool `xorm:"NOT NULL DEFAULT true"`
@ -182,18 +182,18 @@ type Repository struct {
ExternalTrackerURL string
ExternalTrackerFormat string
ExternalTrackerStyle string
ExternalMetas map[string]string `xorm:"-"`
ExternalMetas map[string]string `xorm:"-" json:"-"`
EnablePulls bool `xorm:"NOT NULL DEFAULT true"`
PullsIgnoreWhitespace bool `xorm:"NOT NULL DEFAULT false"`
PullsAllowRebase bool `xorm:"NOT NULL DEFAULT false"`
IsFork bool `xorm:"NOT NULL DEFAULT false"`
ForkID int64
BaseRepo *Repository `xorm:"-"`
BaseRepo *Repository `xorm:"-" json:"-"`
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
Updated time.Time `xorm:"-"`
Updated time.Time `xorm:"-" json:"-"`
UpdatedUnix int64
}

18
models/ssh_key.go

@ -51,12 +51,12 @@ type PublicKey struct {
Mode AccessMode `xorm:"NOT NULL DEFAULT 2"`
Type KeyType `xorm:"NOT NULL DEFAULT 1"`
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
Updated time.Time `xorm:"-"` // Note: Updated must below Created for AfterSet.
Updated time.Time `xorm:"-" json:"-"` // Note: Updated must below Created for AfterSet.
UpdatedUnix int64
HasRecentActivity bool `xorm:"-"`
HasUsed bool `xorm:"-"`
HasRecentActivity bool `xorm:"-" json:"-"`
HasUsed bool `xorm:"-" json:"-"`
}
func (k *PublicKey) BeforeInsert() {
@ -568,14 +568,14 @@ type DeployKey struct {
RepoID int64 `xorm:"UNIQUE(s) INDEX"`
Name string
Fingerprint string
Content string `xorm:"-"`
Content string `xorm:"-" json:"-"`
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
Updated time.Time `xorm:"-"` // Note: Updated must below Created for AfterSet.
Updated time.Time `xorm:"-" json:"-"` // Note: Updated must below Created for AfterSet.
UpdatedUnix int64
HasRecentActivity bool `xorm:"-"`
HasUsed bool `xorm:"-"`
HasRecentActivity bool `xorm:"-" json:"-"`
HasUsed bool `xorm:"-" json:"-"`
}
func (k *DeployKey) BeforeInsert() {

8
models/token.go

@ -20,12 +20,12 @@ type AccessToken struct {
Name string
Sha1 string `xorm:"UNIQUE VARCHAR(40)"`
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
Updated time.Time `xorm:"-"` // Note: Updated must below Created for AfterSet.
Updated time.Time `xorm:"-" json:"-"` // Note: Updated must below Created for AfterSet.
UpdatedUnix int64
HasRecentActivity bool `xorm:"-"`
HasUsed bool `xorm:"-"`
HasRecentActivity bool `xorm:"-" json:"-"`
HasUsed bool `xorm:"-" json:"-"`
}
func (t *AccessToken) BeforeInsert() {

2
models/two_factor.go

@ -25,7 +25,7 @@ type TwoFactor struct {
ID int64
UserID int64 `xorm:"UNIQUE"`
Secret string
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
}

14
models/user.go

@ -55,17 +55,17 @@ type User struct {
LoginSource int64 `xorm:"NOT NULL DEFAULT 0"`
LoginName string
Type UserType
OwnedOrgs []*User `xorm:"-"`
Orgs []*User `xorm:"-"`
Repos []*Repository `xorm:"-"`
OwnedOrgs []*User `xorm:"-" json:"-"`
Orgs []*User `xorm:"-" json:"-"`
Repos []*Repository `xorm:"-" json:"-"`
Location string
Website string
Rands string `xorm:"VARCHAR(10)"`
Salt string `xorm:"VARCHAR(10)"`
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
Updated time.Time `xorm:"-"`
Updated time.Time `xorm:"-" json:"-"`
UpdatedUnix int64
// Remember visibility choice for convenience, true for private
@ -95,8 +95,8 @@ type User struct {
Description string
NumTeams int
NumMembers int
Teams []*Team `xorm:"-"`
Members []*User `xorm:"-"`
Teams []*Team `xorm:"-" json:"-"`
Members []*User `xorm:"-" json:"-"`
}
func (u *User) BeforeInsert() {

2
models/user_mail.go

@ -18,7 +18,7 @@ type EmailAddress struct {
UID int64 `xorm:"INDEX NOT NULL"`
Email string `xorm:"UNIQUE NOT NULL"`
IsActivated bool
IsPrimary bool `xorm:"-"`
IsPrimary bool `xorm:"-" json:"-"`
}
// GetEmailAddresses returns all email addresses belongs to given user.

14
models/webhook.go

@ -99,16 +99,16 @@ type Webhook struct {
ContentType HookContentType
Secret string `xorm:"TEXT"`
Events string `xorm:"TEXT"`
*HookEvent `xorm:"-"`
*HookEvent `xorm:"-" json:"-"`
IsSSL bool `xorm:"is_ssl"`
IsActive bool
HookTaskType HookTaskType
Meta string `xorm:"TEXT"` // store hook-specific attributes
LastStatus HookStatus // Last delivery status
Created time.Time `xorm:"-"`
Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64
Updated time.Time `xorm:"-"`
Updated time.Time `xorm:"-" json:"-"`
UpdatedUnix int64
}
@ -418,21 +418,21 @@ type HookTask struct {
Type HookTaskType
URL string `xorm:"TEXT"`
Signature string `xorm:"TEXT"`
api.Payloader `xorm:"-"`
api.Payloader `xorm:"-" json:"-"`
PayloadContent string `xorm:"TEXT"`
ContentType HookContentType
EventType HookEventType
IsSSL bool
IsDelivered bool
Delivered int64
DeliveredString string `xorm:"-"`
DeliveredString string `xorm:"-" json:"-"`
// History info.
IsSucceed bool
RequestContent string `xorm:"TEXT"`
RequestInfo *HookRequest `xorm:"-"`
RequestInfo *HookRequest `xorm:"-" json:"-"`
ResponseContent string `xorm:"TEXT"`
ResponseInfo *HookResponse `xorm:"-"`
ResponseInfo *HookResponse `xorm:"-" json:"-"`
}
func (t *HookTask) BeforeUpdate() {

Loading…
Cancel
Save