From 159d80f5d04ba07f64ed3a6a8169d4b756eabf80 Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 10 Nov 2021 17:12:46 +0800 Subject: [PATCH 1/3] mod visiable count --- templates/org/home.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index ad5a8e02d..7e9970d2b 100755 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -39,7 +39,7 @@

{{.i18n.Tr "org.people"}}
- {{.Org.NumMembers}} {{svg "octicon-chevron-right" 16}} + {{.MembersTotal}} {{svg "octicon-chevron-right" 16}}
From 61d46048b78fae96b888745fa4a80388f046636f Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Wed, 10 Nov 2021 17:26:06 +0800 Subject: [PATCH 2/3] creator visible --- models/org.go | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 models/org.go diff --git a/models/org.go b/models/org.go old mode 100644 new mode 100755 index 58afc5cb5..e8006d55f --- a/models/org.go +++ b/models/org.go @@ -182,6 +182,7 @@ func CreateOrganization(org, owner *User) (err error) { if _, err = sess.Insert(&OrgUser{ UID: owner.ID, OrgID: org.ID, + IsPublic: setting.Service.DefaultOrgMemberVisible, }); err != nil { return fmt.Errorf("insert org-user relation: %v", err) } From 56780e5d91fa8aa9858cd934da48aebb71fc2eb9 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 10 Nov 2021 17:39:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=9C=8B=E6=9D=BF=E7=95=8C=E9=9D=A2=E6=9F=A5=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=8Agit=20clone=E4=B8=8B=E8=BD=BD=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=E7=BA=A0=E6=AD=A3=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/repo.go | 23 ++++++++++++++++++++++- routers/repo/http.go | 6 ++++++ routers/repo/user_data_analysis.go | 14 ++++++++++++++ routers/routes/routes.go | 2 +- 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/models/repo.go b/models/repo.go index c8629875e..1a5cf122c 100755 --- a/models/repo.go +++ b/models/repo.go @@ -210,9 +210,12 @@ type Repository struct { Balance string `xorm:"NOT NULL DEFAULT '0'"` BlockChainStatus RepoBlockChainStatus `xorm:"NOT NULL DEFAULT 0"` - // git clone total count + // git clone and git pull total count CloneCnt int64 `xorm:"NOT NULL DEFAULT 0"` + // only git clone total count + GitCloneCnt int64 `xorm:"NOT NULL DEFAULT 0"` + CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` @@ -2473,6 +2476,24 @@ func (repo *Repository) IncreaseCloneCnt() { return } +func (repo *Repository) IncreaseGitCloneCnt() { + sess := x.NewSession() + defer sess.Close() + + if err := sess.Begin(); err != nil { + return + } + if _, err := sess.Exec("UPDATE `repository` SET git_clone_cnt = git_clone_cnt + 1 WHERE id = ?", repo.ID); err != nil { + return + } + + if err := sess.Commit(); err != nil { + return + } + + return +} + func UpdateRepositoryCommitNum(repo *Repository) error { if _, err := x.Exec("UPDATE `repository` SET num_commit = ? where id = ?", repo.NumCommit, repo.ID); err != nil { return err diff --git a/routers/repo/http.go b/routers/repo/http.go index ed6276466..ad2abf567 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -317,6 +317,12 @@ func HTTP(ctx *context.Context) { go repo.IncreaseCloneCnt() } + if ctx.Req.Method == "POST" { + if strings.HasSuffix(ctx.Req.URL.Path, "git-upload-pack") { + go repo.IncreaseGitCloneCnt() + } + } + w := ctx.Resp r := ctx.Req.Request cfg := &serviceConfig{ diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 7dc7af321..68cccd478 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -1,13 +1,27 @@ package repo import ( + "fmt" + "net/http" "time" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" ) +func QueryUserStaticData(ctx *context.Context) { + startDate := ctx.Query("startDate") + endDate := ctx.Query("endDate") + log.Info("startDate=" + startDate + " endDate=" + endDate) + startTime, _ := time.Parse("2006-01-02", startDate) + endTime, _ := time.Parse("2006-01-02", endDate) + log.Info("startTime=" + fmt.Sprint(startTime.Unix()) + " endDate=" + fmt.Sprint(endTime.Unix())) + ctx.JSON(http.StatusOK, models.QueryUserStaticData(startTime.Unix(), endTime.Unix())) + +} + func TimingCountDataByDate(date string) { t, _ := time.Parse("2006-01-02", date) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index a4b8f8aa1..9a416f264 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -791,7 +791,7 @@ func RegisterRoutes(m *macaron.Macaron) { }, reqSignIn, context.RepoAssignment(), context.UnitTypes(), reqRepoAdmin, context.RepoRef()) m.Post("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.UnitTypes(), repo.Action) - + m.Get("/tool/query_user_static", repo.QueryUserStaticData) // Grouping for those endpoints not requiring authentication m.Group("/:username/:reponame", func() { m.Group("/milestone", func() {