From b3b3f52225c1810bb903f9eed27d965fe4479a3e Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 18 Oct 2021 10:43:38 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/attachment.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index a8b2c8fbe..8f730dd4c 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -694,6 +694,9 @@ func GetMultipartUploadUrl(ctx *context.Context) { ctx.Error(500, fmt.Sprintf("ObsGenMultiPartSignedUrl failed: %v", err)) return } + + log.Info("url=" + url) + } ctx.JSON(200, map[string]string{ From 5cc2e4b45db0fbd311e5d86bc3eef004de7b6484 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 18 Oct 2021 17:36:34 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=A2=9E=E5=8A=A0OBS?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=90=86=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- modules/setting/setting.go | 5 +++++ modules/storage/obs.go | 29 ++++++++++++++++++++++++++++- routers/repo/attachment.go | 35 ++++++++++++++++++++++++++++------- routers/routes/routes.go | 4 +++- 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index e1e7b7902..509483223 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -490,6 +490,9 @@ var ( Index string TimeField string ElkTimeFormat string + + //nginx proxy + PROXYURL string ) // DateLang transforms standard language locale name to corresponding value in datetime plugin. @@ -1196,6 +1199,7 @@ func NewContext() { Location = sec.Key("LOCATION").MustString("cn-south-222") BasePath = sec.Key("BASE_PATH").MustString("attachment/") UserBasePath = sec.Key("BASE_PATH_USER").MustString("users/") + PROXYURL = sec.Key("PROXY_URL").MustString("") sec = Cfg.Section("modelarts") ModelArtsHost = sec.Key("ENDPOINT").MustString("112.95.163.80") @@ -1217,6 +1221,7 @@ func NewContext() { Index = sec.Key("INDEX").MustString("filebeat-7.3.2*") TimeField = sec.Key("TIMEFIELD").MustString(" @timestamptest") ElkTimeFormat = sec.Key("ELKTIMEFORMAT").MustString("date_time") + } func loadInternalToken(sec *ini.Section) string { diff --git a/modules/storage/obs.go b/modules/storage/obs.go index 77fe49b4e..8685c17b6 100755 --- a/modules/storage/obs.go +++ b/modules/storage/obs.go @@ -5,11 +5,13 @@ package storage import ( - "github.com/unknwon/com" + "io" "path" "strconv" "strings" + "github.com/unknwon/com" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/obs" "code.gitea.io/gitea/modules/setting" @@ -102,6 +104,31 @@ func CompleteObsMultiPartUpload(uuid, uploadID, fileName string) error { return nil } +func ObsMultiPartUpload(uuid string, uploadId string, partNumber int, fileName string, putBody io.ReadCloser) error { + input := &obs.UploadPartInput{} + input.Bucket = setting.Bucket + input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, fileName)), "/") + input.UploadId = uploadId + input.PartNumber = partNumber + input.Body = putBody + output, err := ObsCli.UploadPart(input) + if err == nil { + log.Info("RequestId:%s\n", output.RequestId) + log.Info("ETag:%s\n", output.ETag) + return nil + } else { + if obsError, ok := err.(obs.ObsError); ok { + log.Info(obsError.Code) + log.Info(obsError.Message) + return obsError + } else { + log.Error("error:", err) + return err + } + } + +} + func ObsGenMultiPartSignedUrl(uuid string, uploadId string, partNumber int, fileName string) (string, error) { input := &obs.CreateSignedUrlInput{} diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 8f730dd4c..bd80c070d 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -662,6 +662,24 @@ func NewMultipart(ctx *context.Context) { } } +func PutOBSProxyUpload(ctx *context.Context) { + uuid := ctx.Query("uuid") + uploadID := ctx.Query("uploadId") + partNumber := ctx.QueryInt("partNumber") + fileName := ctx.Query("file_name") + + RequestBody := ctx.Req.Body() + if RequestBody == nil { + ctx.Error(500, fmt.Sprintf("FormFile: %v", RequestBody)) + return + } + + err := storage.ObsMultiPartUpload(uuid, uploadID, partNumber, fileName, RequestBody.ReadCloser()) + if err != nil { + log.Info("upload error.") + } +} + func GetMultipartUploadUrl(ctx *context.Context) { uuid := ctx.Query("uuid") uploadID := ctx.Query("uploadID") @@ -689,14 +707,17 @@ func GetMultipartUploadUrl(ctx *context.Context) { return } } else { - url, err = storage.ObsGenMultiPartSignedUrl(uuid, uploadID, partNumber, fileName) - if err != nil { - ctx.Error(500, fmt.Sprintf("ObsGenMultiPartSignedUrl failed: %v", err)) - return + if setting.PROXYURL != "" { + url = setting.PROXYURL + "?uuid=" + uuid + "&uploadId=" + uploadID + "&partNumber=" + fmt.Sprint(partNumber) + "&file_name=" + fileName + log.Info("return url=" + url) + } else { + url, err = storage.ObsGenMultiPartSignedUrl(uuid, uploadID, partNumber, fileName) + if err != nil { + ctx.Error(500, fmt.Sprintf("ObsGenMultiPartSignedUrl failed: %v", err)) + return + } + log.Info("url=" + url) } - - log.Info("url=" + url) - } ctx.JSON(200, map[string]string{ diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 892368315..1991375a6 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -6,13 +6,14 @@ package routes import ( "bytes" - "code.gitea.io/gitea/routers/operation" "encoding/gob" "net/http" "path" "text/template" "time" + "code.gitea.io/gitea/routers/operation" + "code.gitea.io/gitea/routers/secure" "code.gitea.io/gitea/models" @@ -565,6 +566,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/private", repo.UpdatePublicAttachment) m.Get("/get_chunks", repo.GetSuccessChunks) m.Get("/new_multipart", repo.NewMultipart) + m.Get("/obs_proxy_multipart", repo.PutOBSProxyUpload) m.Get("/get_multipart_url", repo.GetMultipartUploadUrl) m.Post("/complete_multipart", repo.CompleteMultipart) m.Post("/update_chunk", repo.UpdateMultipart) From 90ed05708fb00df07648efe37393801e9aaf5a72 Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 19 Oct 2021 09:14:29 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/routes/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 1991375a6..388499bfc 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -566,7 +566,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/private", repo.UpdatePublicAttachment) m.Get("/get_chunks", repo.GetSuccessChunks) m.Get("/new_multipart", repo.NewMultipart) - m.Get("/obs_proxy_multipart", repo.PutOBSProxyUpload) + m.Put("/obs_proxy_multipart", repo.PutOBSProxyUpload) m.Get("/get_multipart_url", repo.GetMultipartUploadUrl) m.Post("/complete_multipart", repo.CompleteMultipart) m.Post("/update_chunk", repo.UpdateMultipart) From 536a385a28085f8788babe63ed22f0f9f3ba193e Mon Sep 17 00:00:00 2001 From: zouap Date: Tue, 19 Oct 2021 11:44:44 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- modules/storage/obs.go | 19 +++++++++++++++++++ routers/repo/attachment.go | 46 +++++++++++++++++++++++++++++++++++++++------- routers/routes/routes.go | 3 ++- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/modules/storage/obs.go b/modules/storage/obs.go index 8685c17b6..813e9d017 100755 --- a/modules/storage/obs.go +++ b/modules/storage/obs.go @@ -5,6 +5,7 @@ package storage import ( + "fmt" "io" "path" "strconv" @@ -129,6 +130,24 @@ func ObsMultiPartUpload(uuid string, uploadId string, partNumber int, fileName s } +func ObsDownload(uuid string, fileName string) (io.ReadCloser, error) { + input := &obs.GetObjectInput{} + input.Bucket = setting.Bucket + input.Key = strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, fileName)), "/") + output, err := ObsCli.GetObject(input) + if err == nil { + log.Info("StorageClass:%s, ETag:%s, ContentType:%s, ContentLength:%d, LastModified:%s\n", + output.StorageClass, output.ETag, output.ContentType, output.ContentLength, output.LastModified) + return output.Body, nil + } else if obsError, ok := err.(obs.ObsError); ok { + fmt.Printf("Code:%s\n", obsError.Code) + fmt.Printf("Message:%s\n", obsError.Message) + return nil, obsError + } else { + return nil, err + } +} + func ObsGenMultiPartSignedUrl(uuid string, uploadId string, partNumber int, fileName string) (string, error) { input := &obs.CreateSignedUrlInput{} diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index bd80c070d..9468d37db 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -262,10 +262,15 @@ func GetAttachment(ctx *context.Context) { return } } else { - url, err = storage.ObsGetPreSignedUrl(attach.UUID, attach.Name) - if err != nil { - ctx.ServerError("ObsGetPreSignedUrl", err) - return + if setting.PROXYURL != "" { + url = setting.PROXYURL + "/obs_proxy_download?uuid=" + attach.UUID + "&file_name=" + attach.Name + log.Info("return url=" + url) + } else { + url, err = storage.ObsGetPreSignedUrl(attach.UUID, attach.Name) + if err != nil { + ctx.ServerError("ObsGetPreSignedUrl", err) + return + } } } @@ -273,7 +278,6 @@ func GetAttachment(ctx *context.Context) { ctx.ServerError("Update", err) return } - http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusMovedPermanently) } else { fr, err := storage.Attachments.Open(attach.RelativePath()) @@ -282,7 +286,7 @@ func GetAttachment(ctx *context.Context) { return } defer fr.Close() - + log.Info("go here to download.") if err = increaseDownloadCount(attach, dataSet); err != nil { ctx.ServerError("Update", err) return @@ -680,6 +684,34 @@ func PutOBSProxyUpload(ctx *context.Context) { } } +func GetOBSProxyDownload(ctx *context.Context) { + uuid := ctx.Query("uuid") + fileName := ctx.Query("file_name") + + body, err := storage.ObsDownload(uuid, fileName) + if err != nil { + log.Info("upload error.") + } else { + defer body.Close() + ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+fileName) + ctx.Resp.Header().Set("Content-Type", "application/octet-stream") + p := make([]byte, 1024) + var readErr error + var readCount int + // 读取对象内容 + for { + readCount, readErr = body.Read(p) + if readCount > 0 { + ctx.Resp.Write(p[:readCount]) + //fmt.Printf("%s", p[:readCount]) + } + if readErr != nil { + break + } + } + } +} + func GetMultipartUploadUrl(ctx *context.Context) { uuid := ctx.Query("uuid") uploadID := ctx.Query("uploadID") @@ -708,7 +740,7 @@ func GetMultipartUploadUrl(ctx *context.Context) { } } else { if setting.PROXYURL != "" { - url = setting.PROXYURL + "?uuid=" + uuid + "&uploadId=" + uploadID + "&partNumber=" + fmt.Sprint(partNumber) + "&file_name=" + fileName + url = setting.PROXYURL + "/obs_proxy_multipart?uuid=" + uuid + "&uploadId=" + uploadID + "&partNumber=" + fmt.Sprint(partNumber) + "&file_name=" + fileName log.Info("return url=" + url) } else { url, err = storage.ObsGenMultiPartSignedUrl(uuid, uploadID, partNumber, fileName) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 388499bfc..0a17c832c 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -13,6 +13,7 @@ import ( "time" "code.gitea.io/gitea/routers/operation" + "code.gitea.io/gitea/routers/private" "code.gitea.io/gitea/routers/secure" @@ -34,7 +35,6 @@ import ( "code.gitea.io/gitea/routers/dev" "code.gitea.io/gitea/routers/events" "code.gitea.io/gitea/routers/org" - "code.gitea.io/gitea/routers/private" "code.gitea.io/gitea/routers/repo" "code.gitea.io/gitea/routers/user" userSetting "code.gitea.io/gitea/routers/user/setting" @@ -567,6 +567,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/get_chunks", repo.GetSuccessChunks) m.Get("/new_multipart", repo.NewMultipart) m.Put("/obs_proxy_multipart", repo.PutOBSProxyUpload) + m.Get("/obs_proxy_download", repo.GetOBSProxyDownload) m.Get("/get_multipart_url", repo.GetMultipartUploadUrl) m.Post("/complete_multipart", repo.CompleteMultipart) m.Post("/update_chunk", repo.UpdateMultipart) From ed70878e6c989ddee1221c6528db71aa3345469d Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Oct 2021 10:46:15 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=BF=90=E8=90=A5=E5=88=86=E6=9E=90=E6=8C=87=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=AE=B5=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index a7d549cd4..2d7646127 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -71,6 +71,49 @@ type UserBusinessAnalysis struct { Name string `xorm:"NOT NULL"` } +func QueryUserStaticData(startTime int64, endTime int64) []*UserBusinessAnalysis { + log.Info("query startTime =" + fmt.Sprint(startTime) + " endTime=" + fmt.Sprint(endTime)) + statictisSess := xStatistic.NewSession() + defer statictisSess.Close() + + statictisSess.Select("*").Table("user_business_analysis").Where(" count_date>=" + fmt.Sprint(startTime) + " and count_date<=" + fmt.Sprint(endTime)).OrderBy("count_date desc") + + userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) + statictisSess.Find(&userBusinessAnalysisList) + + resultMap := make(map[int64]*UserBusinessAnalysis) + log.Info("query result size=" + fmt.Sprint(len(userBusinessAnalysisList))) + for _, userRecord := range userBusinessAnalysisList { + if _, ok := resultMap[userRecord.ID]; !ok { + resultMap[userRecord.ID] = userRecord + } else { + resultMap[userRecord.ID].CodeMergeCount += userRecord.CodeMergeCount + resultMap[userRecord.ID].CommitCount += userRecord.CommitCount + resultMap[userRecord.ID].IssueCount += userRecord.IssueCount + resultMap[userRecord.ID].CommentCount += userRecord.CommentCount + resultMap[userRecord.ID].FocusRepoCount += userRecord.FocusRepoCount + resultMap[userRecord.ID].StarRepoCount += userRecord.StarRepoCount + resultMap[userRecord.ID].WatchedCount += userRecord.WatchedCount + resultMap[userRecord.ID].CommitCodeSize += userRecord.CommitCodeSize + resultMap[userRecord.ID].CommitDatasetSize += userRecord.CommitDatasetSize + resultMap[userRecord.ID].CommitModelCount += userRecord.CommitModelCount + resultMap[userRecord.ID].SolveIssueCount += userRecord.SolveIssueCount + resultMap[userRecord.ID].EncyclopediasCount += userRecord.EncyclopediasCount + resultMap[userRecord.ID].CreateRepoCount += userRecord.CreateRepoCount + resultMap[userRecord.ID].LoginCount += userRecord.LoginCount + } + } + + userBusinessAnalysisReturnList := make([]*UserBusinessAnalysis, len(resultMap)) + index := 0 + for _, v := range resultMap { + userBusinessAnalysisReturnList[index] = v + index += 1 + } + log.Info("return size=" + fmt.Sprint(len(userBusinessAnalysisReturnList))) + return userBusinessAnalysisReturnList +} + func CountData(wikiCountMap map[string]int) { log.Info("start to count other user info data") sess := x.NewSession() From 35c83d5b3953b72f9f99463508782bf48128ade7 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Oct 2021 11:08:28 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/attachment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 9468d37db..59f297a49 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -286,7 +286,6 @@ func GetAttachment(ctx *context.Context) { return } defer fr.Close() - log.Info("go here to download.") if err = increaseDownloadCount(attach, dataSet); err != nil { ctx.ServerError("Update", err) return @@ -673,6 +672,7 @@ func PutOBSProxyUpload(ctx *context.Context) { fileName := ctx.Query("file_name") RequestBody := ctx.Req.Body() + if RequestBody == nil { ctx.Error(500, fmt.Sprintf("FormFile: %v", RequestBody)) return From ad2437d987d54d29d03e14966db036d118922966 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Oct 2021 15:03:49 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- modules/storage/obs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/storage/obs.go b/modules/storage/obs.go index 813e9d017..d5817fd3f 100755 --- a/modules/storage/obs.go +++ b/modules/storage/obs.go @@ -123,7 +123,7 @@ func ObsMultiPartUpload(uuid string, uploadId string, partNumber int, fileName s log.Info(obsError.Message) return obsError } else { - log.Error("error:", err) + log.Error("error:", err.Error()) return err } } From 6610963b6476f43993adeb66e2fc8bf75c74ab34 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Oct 2021 15:30:53 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=A0=87=E6=B3=A8=E4=BB=BB=E5=8A=A1=E6=98=BE=E7=A4=BA=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/datasets/label/index.tmpl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/repo/datasets/label/index.tmpl b/templates/repo/datasets/label/index.tmpl index cb268c5b9..72ab3cb57 100644 --- a/templates/repo/datasets/label/index.tmpl +++ b/templates/repo/datasets/label/index.tmpl @@ -69,7 +69,9 @@ @@ -123,7 +125,9 @@ From d8eb2ac14f819aa90e8a65e0fd457fa009ab1ba2 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Oct 2021 15:33:14 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=A0=87=E6=B3=A8=E4=BB=BB=E5=8A=A1=E6=98=BE=E7=A4=BA=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/datasets/label/index.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/repo/datasets/label/index.tmpl b/templates/repo/datasets/label/index.tmpl index 72ab3cb57..ff7f74bca 100644 --- a/templates/repo/datasets/label/index.tmpl +++ b/templates/repo/datasets/label/index.tmpl @@ -69,7 +69,7 @@ {{if .Attachments}} {{range .Attachments}} - {{if eq .DecompressState "1"}} + {{if eq .DecompressState 1}} {{end}} {{end}} From a5565e92020def5e90d88200ebd008fcd0b3e802 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Oct 2021 15:39:56 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E5=9B=9E=E9=80=80=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- templates/repo/datasets/label/index.tmpl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/templates/repo/datasets/label/index.tmpl b/templates/repo/datasets/label/index.tmpl index ff7f74bca..9a0863974 100644 --- a/templates/repo/datasets/label/index.tmpl +++ b/templates/repo/datasets/label/index.tmpl @@ -69,9 +69,7 @@ @@ -125,9 +123,7 @@ From 7cd4defc0adb6a702518a22dfb88abc900886d90 Mon Sep 17 00:00:00 2001 From: zouap Date: Thu, 21 Oct 2021 15:50:22 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=A0=87=E6=B3=A8=E4=BB=BB=E5=8A=A1=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- public/self/labelTaskPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/self/labelTaskPage.js b/public/self/labelTaskPage.js index a160c3961..03acd6df1 100644 --- a/public/self/labelTaskPage.js +++ b/public/self/labelTaskPage.js @@ -309,11 +309,11 @@ function label_task_create(task_name, relate_task_id, taskType,assign_user_id,la success:function(res){ console.log(res); if(res.code == 0){ - alert("自动标注任务创建成功!"); + alert("标注任务创建成功!"); createsucced = true; } else{ - alert("创建自动标注任务失败," + res.message); + alert("创建标注任务失败," + res.message); createsucced = false; } }, From 81e7ac0228721fde7b1021b08010a594544a4b59 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 22 Oct 2021 09:54:39 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 27 ++++++++++++++++++++++++--- routers/repo/attachment.go | 2 ++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 2d7646127..8b7691677 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -135,7 +135,7 @@ func CountData(wikiCountMap map[string]int) { CountDate := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 1, 0, 0, currentTimeNow.Location()) - CodeMergeCountMap := queryAction(start_unix, end_unix, 11) + CodeMergeCountMap := queryPullRequest(start_unix, end_unix) CommitCountMap := queryAction(start_unix, end_unix, 5) IssueCountMap := queryAction(start_unix, end_unix, 10) @@ -266,6 +266,28 @@ func querySolveIssue(start_unix int64, end_unix int64) map[int64]int { } +func queryPullRequest(start_unix int64, end_unix int64) map[int64]int { + sess := x.NewSession() + defer sess.Close() + + sess.Select("issue.*").Table("issue"). + Join("inner", "pull_request", "issue.id=pull_request.issue_id"). + Where("pull_request.merged_unix>=" + fmt.Sprint(start_unix) + " and pull_request.merged_unix<=" + fmt.Sprint(end_unix)) + + issueList := make([]*Issue, 0) + sess.Find(&issueList) + resultMap := make(map[int64]int) + log.Info("query issue(PR) size=" + fmt.Sprint(len(issueList))) + for _, issueRecord := range issueList { + if _, ok := resultMap[issueRecord.PosterID]; !ok { + resultMap[issueRecord.PosterID] = 1 + } else { + resultMap[issueRecord.PosterID] += 1 + } + } + return resultMap +} + func queryAction(start_unix int64, end_unix int64, actionType int64) map[int64]int { sess := x.NewSession() defer sess.Close() @@ -384,7 +406,7 @@ func queryDatasetSize(start_unix int64, end_unix int64) map[int64]int { func queryUserCreateRepo(start_unix int64, end_unix int64) map[int64]int { sess := x.NewSession() defer sess.Close() - sess.Select("id,owner_id,name").Table("repository").Where(" created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix)) + sess.Select("id,owner_id,name").Table("repository").Where("is_fork=false and created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix)) repoList := make([]*Repository, 0) sess.Find(&repoList) resultMap := make(map[int64]int) @@ -397,7 +419,6 @@ func queryUserCreateRepo(start_unix int64, end_unix int64) map[int64]int { } } return resultMap - } func subMonth(t1, t2 time.Time) (month int) { diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 59f297a49..ae148d3f6 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -146,6 +146,8 @@ func DeleteAttachment(ctx *context.Context) { DeleteAllUnzipFile(attach, "") + TimingCountData() + _, err = models.DeleteFileChunkById(attach.UUID) if err != nil { ctx.Error(500, fmt.Sprintf("DeleteFileChunkById: %v", err)) From f580580485476203a48c2ed20b7350983a536bb7 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 22 Oct 2021 10:29:25 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/attachment.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index ae148d3f6..59f297a49 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -146,8 +146,6 @@ func DeleteAttachment(ctx *context.Context) { DeleteAllUnzipFile(attach, "") - TimingCountData() - _, err = models.DeleteFileChunkById(attach.UUID) if err != nil { ctx.Error(500, fmt.Sprintf("DeleteFileChunkById: %v", err))