summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorlunnyxiao <xiaolunwen@gmail.com>2014-08-29 11:25:03 +0800
committerlunnyxiao <xiaolunwen@gmail.com>2014-08-29 11:25:03 +0800
commita6ec6def8dde232cf250e95ef95b14950031771e (patch)
tree892e5eb38fd4057aebc9576dcd88e23dcfd85772 /models
parentc40e815763f8360b892cc5bbdd09725c1df6902f (diff)
parent1aec1a2ddae3a3714d6a167d85fcc1c69413b660 (diff)
downloadgitea-a6ec6def8dde232cf250e95ef95b14950031771e.tar.gz
gitea-a6ec6def8dde232cf250e95ef95b14950031771e.zip
Merge branch 'dev' of github.com:gogits/gogs into dev
Diffstat (limited to 'models')
-rw-r--r--models/models.go21
-rw-r--r--models/org.go6
-rw-r--r--models/user.go18
3 files changed, 31 insertions, 14 deletions
diff --git a/models/models.go b/models/models.go
index 186ddf41aa..4e2e08cf83 100644
--- a/models/models.go
+++ b/models/models.go
@@ -143,27 +143,38 @@ func NewEngine() (err error) {
type Statistic struct {
Counter struct {
- User, PublicKey, Repo, Watch, Action, Access,
- Issue, Comment, Mirror, Oauth, Release,
- LoginSource, Webhook, Milestone int64
+ User, Org, PublicKey,
+ Repo, Watch, Star, Action, Access,
+ Issue, Comment, Oauth, Follow,
+ Mirror, Release, LoginSource, Webhook,
+ Milestone, Label, HookTask,
+ Team, UpdateTask, Attachment int64
}
}
func GetStatistic() (stats Statistic) {
stats.Counter.User = CountUsers()
- stats.Counter.Repo = CountRepositories()
+ stats.Counter.Org = CountOrganizations()
stats.Counter.PublicKey, _ = x.Count(new(PublicKey))
+ stats.Counter.Repo = CountRepositories()
stats.Counter.Watch, _ = x.Count(new(Watch))
+ stats.Counter.Star, _ = x.Count(new(Star))
stats.Counter.Action, _ = x.Count(new(Action))
stats.Counter.Access, _ = x.Count(new(Access))
stats.Counter.Issue, _ = x.Count(new(Issue))
stats.Counter.Comment, _ = x.Count(new(Comment))
- stats.Counter.Mirror, _ = x.Count(new(Mirror))
stats.Counter.Oauth, _ = x.Count(new(Oauth2))
+ stats.Counter.Follow, _ = x.Count(new(Follow))
+ stats.Counter.Mirror, _ = x.Count(new(Mirror))
stats.Counter.Release, _ = x.Count(new(Release))
stats.Counter.LoginSource, _ = x.Count(new(LoginSource))
stats.Counter.Webhook, _ = x.Count(new(Webhook))
stats.Counter.Milestone, _ = x.Count(new(Milestone))
+ stats.Counter.Label, _ = x.Count(new(Label))
+ stats.Counter.HookTask, _ = x.Count(new(HookTask))
+ stats.Counter.Team, _ = x.Count(new(Team))
+ stats.Counter.UpdateTask, _ = x.Count(new(UpdateTask))
+ stats.Counter.Attachment, _ = x.Count(new(Attachment))
return
}
diff --git a/models/org.go b/models/org.go
index 1c74c290e9..18ed68e6f4 100644
--- a/models/org.go
+++ b/models/org.go
@@ -159,6 +159,12 @@ func CreateOrganization(org, owner *User) (*User, error) {
return org, sess.Commit()
}
+// CountOrganizations returns number of organizations.
+func CountOrganizations() int64 {
+ count, _ := x.Where("type=1").Count(new(User))
+ return count
+}
+
// TODO: need some kind of mechanism to record failure.
// DeleteOrganization completely and permanently deletes everything of organization.
func DeleteOrganization(org *User) (err error) {
diff --git a/models/user.go b/models/user.go
index a74d803972..661fb1c220 100644
--- a/models/user.go
+++ b/models/user.go
@@ -45,13 +45,13 @@ var (
// User represents the object of individual and member of organization.
type User struct {
Id int64
- LowerName string `xorm:"unique not null"`
- Name string `xorm:"unique not null"`
+ LowerName string `xorm:"UNIQUE NOT NULL"`
+ Name string `xorm:"UNIQUE NOT NULL"`
FullName string
- Email string `xorm:"unique not null"`
- Passwd string `xorm:"not null"`
+ Email string `xorm:"UNIQUE NOT NULL"`
+ Passwd string `xorm:"NOT NULL"`
LoginType LoginType
- LoginSource int64 `xorm:"not null default 0"`
+ LoginSource int64 `xorm:"NOT NULL DEFAULT 0"`
LoginName string
Type UserType
Orgs []*User `xorm:"-"`
@@ -60,16 +60,16 @@ type User struct {
NumFollowings int
NumStars int
NumRepos int
- Avatar string `xorm:"varchar(2048) not null"`
- AvatarEmail string `xorm:"not null"`
+ Avatar string `xorm:"VARCHAR(2048) NOT NULL"`
+ AvatarEmail string `xorm:"NOT NULL"`
Location string
Website string
IsActive bool
IsAdmin bool
Rands string `xorm:"VARCHAR(10)"`
Salt string `xorm:"VARCHAR(10)"`
- Created time.Time `xorm:"created"`
- Updated time.Time `xorm:"updated"`
+ Created time.Time `xorm:"CREATED"`
+ Updated time.Time `xorm:"UPDATED"`
// For organization.
Description string