mirror of
https://github.com/minoplhy/scriptbox.git
synced 2024-12-04 17:36:57 +00:00
240 lines
17 KiB
Diff
240 lines
17 KiB
Diff
diff --git a/routers/web/repo/code_frequency.go b/routers/web/repo/code_frequency.go
|
|
index c76f492da0..1933277468 100644
|
|
--- a/routers/web/repo/code_frequency.go
|
|
+++ b/routers/web/repo/code_frequency.go
|
|
@@ -4,38 +4,23 @@
|
|
package repo
|
|
|
|
import (
|
|
- "errors"
|
|
"net/http"
|
|
|
|
- "code.gitea.io/gitea/modules/base"
|
|
+ //"code.gitea.io/gitea/modules/base"
|
|
"code.gitea.io/gitea/services/context"
|
|
- contributors_service "code.gitea.io/gitea/services/repository"
|
|
)
|
|
|
|
-const (
|
|
- tplCodeFrequency base.TplName = "repo/activity"
|
|
-)
|
|
+// const (
|
|
+// tplCodeFrequency base.TplName = "repo/activity"
|
|
+// )
|
|
|
|
// CodeFrequency renders the page to show repository code frequency
|
|
func CodeFrequency(ctx *context.Context) {
|
|
- ctx.Data["Title"] = ctx.Tr("repo.activity.navbar.code_frequency")
|
|
-
|
|
- ctx.Data["PageIsActivity"] = true
|
|
- ctx.Data["PageIsCodeFrequency"] = true
|
|
- ctx.PageData["repoLink"] = ctx.Repo.RepoLink
|
|
+ ctx.Status(http.StatusNotFound)
|
|
|
|
- ctx.HTML(http.StatusOK, tplCodeFrequency)
|
|
}
|
|
|
|
// CodeFrequencyData returns JSON of code frequency data
|
|
func CodeFrequencyData(ctx *context.Context) {
|
|
- if contributorStats, err := contributors_service.GetContributorStats(ctx, ctx.Cache, ctx.Repo.Repository, ctx.Repo.CommitID); err != nil {
|
|
- if errors.Is(err, contributors_service.ErrAwaitGeneration) {
|
|
- ctx.Status(http.StatusAccepted)
|
|
- return
|
|
- }
|
|
- ctx.ServerError("GetCodeFrequencyData", err)
|
|
- } else {
|
|
- ctx.JSON(http.StatusOK, contributorStats["total"].Weeks)
|
|
- }
|
|
+ ctx.Status(http.StatusNotFound)
|
|
}
|
|
diff --git a/routers/web/repo/contributors.go b/routers/web/repo/contributors.go
|
|
index 762fbf9379..739ee5948c 100644
|
|
--- a/routers/web/repo/contributors.go
|
|
+++ b/routers/web/repo/contributors.go
|
|
@@ -4,35 +4,22 @@
|
|
package repo
|
|
|
|
import (
|
|
- "errors"
|
|
"net/http"
|
|
|
|
- "code.gitea.io/gitea/modules/base"
|
|
+ //"code.gitea.io/gitea/modules/base"
|
|
"code.gitea.io/gitea/services/context"
|
|
- contributors_service "code.gitea.io/gitea/services/repository"
|
|
)
|
|
|
|
-const (
|
|
- tplContributors base.TplName = "repo/activity"
|
|
-)
|
|
+// const (
|
|
+// tplContributors base.TplName = "repo/activity"
|
|
+// )
|
|
|
|
// Contributors render the page to show repository contributors graph
|
|
func Contributors(ctx *context.Context) {
|
|
- ctx.Data["Title"] = ctx.Tr("repo.activity.navbar.contributors")
|
|
- ctx.Data["PageIsActivity"] = true
|
|
- ctx.Data["PageIsContributors"] = true
|
|
- ctx.HTML(http.StatusOK, tplContributors)
|
|
+ ctx.Status(http.StatusNotFound)
|
|
}
|
|
|
|
// ContributorsData renders JSON of contributors along with their weekly commit statistics
|
|
func ContributorsData(ctx *context.Context) {
|
|
- if contributorStats, err := contributors_service.GetContributorStats(ctx, ctx.Cache, ctx.Repo.Repository, ctx.Repo.CommitID); err != nil {
|
|
- if errors.Is(err, contributors_service.ErrAwaitGeneration) {
|
|
- ctx.Status(http.StatusAccepted)
|
|
- return
|
|
- }
|
|
- ctx.ServerError("GetContributorStats", err)
|
|
- } else {
|
|
- ctx.JSON(http.StatusOK, contributorStats)
|
|
- }
|
|
+ ctx.Status(http.StatusNotFound)
|
|
}
|
|
diff --git a/routers/web/repo/recent_commits.go b/routers/web/repo/recent_commits.go
|
|
index c158fb30b6..f58c0c60f6 100644
|
|
--- a/routers/web/repo/recent_commits.go
|
|
+++ b/routers/web/repo/recent_commits.go
|
|
@@ -4,38 +4,22 @@
|
|
package repo
|
|
|
|
import (
|
|
- "errors"
|
|
"net/http"
|
|
|
|
- "code.gitea.io/gitea/modules/base"
|
|
+ //"code.gitea.io/gitea/modules/base"
|
|
"code.gitea.io/gitea/services/context"
|
|
- contributors_service "code.gitea.io/gitea/services/repository"
|
|
)
|
|
|
|
-const (
|
|
- tplRecentCommits base.TplName = "repo/activity"
|
|
-)
|
|
+// const (
|
|
+// tplRecentCommits base.TplName = "repo/activity"
|
|
+// )
|
|
|
|
// RecentCommits renders the page to show recent commit frequency on repository
|
|
func RecentCommits(ctx *context.Context) {
|
|
- ctx.Data["Title"] = ctx.Tr("repo.activity.navbar.recent_commits")
|
|
-
|
|
- ctx.Data["PageIsActivity"] = true
|
|
- ctx.Data["PageIsRecentCommits"] = true
|
|
- ctx.PageData["repoLink"] = ctx.Repo.RepoLink
|
|
-
|
|
- ctx.HTML(http.StatusOK, tplRecentCommits)
|
|
+ ctx.Status(http.StatusNotFound)
|
|
}
|
|
|
|
// RecentCommitsData returns JSON of recent commits data
|
|
func RecentCommitsData(ctx *context.Context) {
|
|
- if contributorStats, err := contributors_service.GetContributorStats(ctx, ctx.Cache, ctx.Repo.Repository, ctx.Repo.CommitID); err != nil {
|
|
- if errors.Is(err, contributors_service.ErrAwaitGeneration) {
|
|
- ctx.Status(http.StatusAccepted)
|
|
- return
|
|
- }
|
|
- ctx.ServerError("RecentCommitsData", err)
|
|
- } else {
|
|
- ctx.JSON(http.StatusOK, contributorStats["total"].Weeks)
|
|
- }
|
|
+ ctx.Status(http.StatusNotFound)
|
|
}
|
|
diff --git a/routers/web/web.go b/routers/web/web.go
|
|
index 5e19d1fd13..d99e206ea5 100644
|
|
--- a/routers/web/web.go
|
|
+++ b/routers/web/web.go
|
|
@@ -1436,18 +1436,6 @@ func registerRoutes(m *web.Route) {
|
|
m.Group("/{username}/{reponame}/activity", func() {
|
|
m.Get("", repo.Activity)
|
|
m.Get("/{period}", repo.Activity)
|
|
- m.Group("/contributors", func() {
|
|
- m.Get("", repo.Contributors)
|
|
- m.Get("/data", repo.ContributorsData)
|
|
- })
|
|
- m.Group("/code-frequency", func() {
|
|
- m.Get("", repo.CodeFrequency)
|
|
- m.Get("/data", repo.CodeFrequencyData)
|
|
- })
|
|
- m.Group("/recent-commits", func() {
|
|
- m.Get("", repo.RecentCommits)
|
|
- m.Get("/data", repo.RecentCommitsData)
|
|
- })
|
|
},
|
|
ignSignIn, context.RepoAssignment, context.RequireRepoReaderOr(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases),
|
|
context.RepoRef(), repo.MustBeNotEmpty,
|
|
diff --git a/services/repository/contributors_graph.go b/services/repository/contributors_graph.go
|
|
index b0748f8ee3..399aa2076d 100644
|
|
--- a/services/repository/contributors_graph.go
|
|
+++ b/services/repository/contributors_graph.go
|
|
@@ -80,34 +80,7 @@ func findLastSundayBeforeDate(dateStr string) (string, error) {
|
|
// GetContributorStats returns contributors stats for git commits for given revision or default branch
|
|
func GetContributorStats(ctx context.Context, cache cache.StringCache, repo *repo_model.Repository, revision string) (map[string]*ContributorData, error) {
|
|
// as GetContributorStats is resource intensive we cache the result
|
|
- cacheKey := fmt.Sprintf(contributorStatsCacheKey, repo.FullName(), revision)
|
|
- if !cache.IsExist(cacheKey) {
|
|
- genReady := make(chan struct{})
|
|
-
|
|
- // dont start multiple async generations
|
|
- _, run := generateLock.Load(cacheKey)
|
|
- if run {
|
|
- return nil, ErrAwaitGeneration
|
|
- }
|
|
-
|
|
- generateLock.Store(cacheKey, struct{}{})
|
|
- // run generation async
|
|
- go generateContributorStats(genReady, cache, cacheKey, repo, revision)
|
|
-
|
|
- select {
|
|
- case <-time.After(awaitGenerationTime):
|
|
- return nil, ErrAwaitGeneration
|
|
- case <-genReady:
|
|
- // we got generation ready before timeout
|
|
- break
|
|
- }
|
|
- }
|
|
- // TODO: renew timeout of cache cache.UpdateTimeout(cacheKey, contributorStatsCacheTimeout)
|
|
- var res map[string]*ContributorData
|
|
- if _, cacheErr := cache.GetJSON(cacheKey, &res); cacheErr != nil {
|
|
- return nil, fmt.Errorf("cached error: %w", cacheErr.ToError())
|
|
- }
|
|
- return res, nil
|
|
+ return nil, nil
|
|
}
|
|
|
|
// getExtendedCommitStats return the list of *ExtendedCommitStats for the given revision
|
|
diff --git a/templates/repo/activity.tmpl b/templates/repo/activity.tmpl
|
|
index a19fb66261..4973f66391 100644
|
|
--- a/templates/repo/activity.tmpl
|
|
+++ b/templates/repo/activity.tmpl
|
|
@@ -7,9 +7,6 @@
|
|
</div>
|
|
<div class="flex-container-main">
|
|
{{if .PageIsPulse}}{{template "repo/pulse" .}}{{end}}
|
|
- {{if .PageIsContributors}}{{template "repo/contributors" .}}{{end}}
|
|
- {{if .PageIsCodeFrequency}}{{template "repo/code_frequency" .}}{{end}}
|
|
- {{if .PageIsRecentCommits}}{{template "repo/recent_commits" .}}{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
diff --git a/templates/repo/navbar.tmpl b/templates/repo/navbar.tmpl
|
|
index b2471dc17e..3466f0bfaf 100644
|
|
--- a/templates/repo/navbar.tmpl
|
|
+++ b/templates/repo/navbar.tmpl
|
|
@@ -2,13 +2,4 @@
|
|
<a class="{{if .PageIsPulse}}active {{end}}item" href="{{.RepoLink}}/activity">
|
|
{{ctx.Locale.Tr "repo.activity.navbar.pulse"}}
|
|
</a>
|
|
- <a class="{{if .PageIsContributors}}active {{end}}item" href="{{.RepoLink}}/activity/contributors">
|
|
- {{ctx.Locale.Tr "repo.activity.navbar.contributors"}}
|
|
- </a>
|
|
- <a class="{{if .PageIsCodeFrequency}}active{{end}} item" href="{{.RepoLink}}/activity/code-frequency">
|
|
- {{ctx.Locale.Tr "repo.activity.navbar.code_frequency"}}
|
|
- </a>
|
|
- <a class="{{if .PageIsRecentCommits}}active{{end}} item" href="{{.RepoLink}}/activity/recent-commits">
|
|
- {{ctx.Locale.Tr "repo.activity.navbar.recent_commits"}}
|
|
- </a>
|
|
</div>
|