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 OpType ActionType
ActUserID int64 // Doer user ID ActUserID int64 // Doer user ID
ActUserName string // Doer user name ActUserName string // Doer user name
ActAvatar string `xorm:"-"` ActAvatar string `xorm:"-" json:"-"`
RepoID int64 `xorm:"INDEX"` RepoID int64 `xorm:"INDEX"`
RepoUserName string RepoUserName string
RepoName string RepoName string
RefName string RefName string
IsPrivate bool `xorm:"NOT NULL DEFAULT false"` IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
Content string `xorm:"TEXT"` Content string `xorm:"TEXT"`
Created time.Time `xorm:"-"` Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64 CreatedUnix int64
} }

2
models/admin.go

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

2
models/attachment.go

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

14
models/comment.go

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

26
models/issue.go

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

4
models/issue_label.go

@ -60,8 +60,8 @@ type Label struct {
Color string `xorm:"VARCHAR(7)"` Color string `xorm:"VARCHAR(7)"`
NumIssues int NumIssues int
NumClosedIssues int NumClosedIssues int
NumOpenIssues int `xorm:"-"` NumOpenIssues int `xorm:"-" json:"-"`
IsChecked bool `xorm:"-"` IsChecked bool `xorm:"-" json:"-"`
} }
func (label *Label) APIFormat() *api.Label { 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"` IsActived bool `xorm:"NOT NULL DEFAULT false"`
Cfg core.Conversion `xorm:"TEXT"` Cfg core.Conversion `xorm:"TEXT"`
Created time.Time `xorm:"-"` Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64 CreatedUnix int64
Updated time.Time `xorm:"-"` Updated time.Time `xorm:"-" json:"-"`
UpdatedUnix int64 UpdatedUnix int64
LocalFile *AuthSourceFile `xorm:"-"` LocalFile *AuthSourceFile `xorm:"-" json:"-"`
} }
func (s *LoginSource) BeforeInsert() { func (s *LoginSource) BeforeInsert() {

12
models/milestone.go

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

8
models/mirror.go

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

4
models/org_team.go

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

10
models/pull.go

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

10
models/release.go

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

20
models/repo.go

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

18
models/ssh_key.go

@ -51,12 +51,12 @@ type PublicKey struct {
Mode AccessMode `xorm:"NOT NULL DEFAULT 2"` Mode AccessMode `xorm:"NOT NULL DEFAULT 2"`
Type KeyType `xorm:"NOT NULL DEFAULT 1"` Type KeyType `xorm:"NOT NULL DEFAULT 1"`
Created time.Time `xorm:"-"` Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64 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 UpdatedUnix int64
HasRecentActivity bool `xorm:"-"` HasRecentActivity bool `xorm:"-" json:"-"`
HasUsed bool `xorm:"-"` HasUsed bool `xorm:"-" json:"-"`
} }
func (k *PublicKey) BeforeInsert() { func (k *PublicKey) BeforeInsert() {
@ -568,14 +568,14 @@ type DeployKey struct {
RepoID int64 `xorm:"UNIQUE(s) INDEX"` RepoID int64 `xorm:"UNIQUE(s) INDEX"`
Name string Name string
Fingerprint string Fingerprint string
Content string `xorm:"-"` Content string `xorm:"-" json:"-"`
Created time.Time `xorm:"-"` Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64 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 UpdatedUnix int64
HasRecentActivity bool `xorm:"-"` HasRecentActivity bool `xorm:"-" json:"-"`
HasUsed bool `xorm:"-"` HasUsed bool `xorm:"-" json:"-"`
} }
func (k *DeployKey) BeforeInsert() { func (k *DeployKey) BeforeInsert() {

8
models/token.go

@ -20,12 +20,12 @@ type AccessToken struct {
Name string Name string
Sha1 string `xorm:"UNIQUE VARCHAR(40)"` Sha1 string `xorm:"UNIQUE VARCHAR(40)"`
Created time.Time `xorm:"-"` Created time.Time `xorm:"-" json:"-"`
CreatedUnix int64 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 UpdatedUnix int64
HasRecentActivity bool `xorm:"-"` HasRecentActivity bool `xorm:"-" json:"-"`
HasUsed bool `xorm:"-"` HasUsed bool `xorm:"-" json:"-"`
} }
func (t *AccessToken) BeforeInsert() { func (t *AccessToken) BeforeInsert() {

2
models/two_factor.go

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

14
models/user.go

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

2
models/user_mail.go

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

14
models/webhook.go

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

Loading…
Cancel
Save