summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2020-02-11 11:34:17 +0200
committerGitHub <noreply@github.com>2020-02-11 11:34:17 +0200
commitad2642a8aac9facb217a8471df1d3e00f1214e92 (patch)
treeea198b2b3130d22bb60886b6ba0a1df352f160ff /routers
parent37892be63580e40ced80e041ff2e7dabb2e80866 (diff)
downloadgitea-ad2642a8aac9facb217a8471df1d3e00f1214e92.tar.gz
gitea-ad2642a8aac9facb217a8471df1d3e00f1214e92.zip
Language statistics bar for repositories (#8037)
* Implementation for calculating language statistics Impement saving code language statistics to database Implement rendering langauge stats Add primary laguage to show in repository list Implement repository stats indexer queue Add indexer test Refactor to use queue module * Do not timeout for queues
Diffstat (limited to 'routers')
-rw-r--r--routers/init.go4
-rw-r--r--routers/org/home.go1
-rw-r--r--routers/repo/view.go15
-rw-r--r--routers/user/profile.go1
4 files changed, 19 insertions, 2 deletions
diff --git a/routers/init.go b/routers/init.go
index f86a7ad4b2..724bf84c10 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -19,6 +19,7 @@ import (
"code.gitea.io/gitea/modules/highlight"
code_indexer "code.gitea.io/gitea/modules/indexer/code"
issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
+ stats_indexer "code.gitea.io/gitea/modules/indexer/stats"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/external"
@@ -111,6 +112,9 @@ func GlobalInit(ctx context.Context) {
cron.NewContext()
issue_indexer.InitIssueIndexer(false)
code_indexer.Init()
+ if err := stats_indexer.Init(); err != nil {
+ log.Fatal("Failed to initialize repository stats indexer queue: %v", err)
+ }
mirror_service.InitSyncMirrors()
webhook.InitDeliverHooks()
if err := pull_service.Init(); err != nil {
diff --git a/routers/org/home.go b/routers/org/home.go
index e1bea5b7a6..fa61218d3f 100644
--- a/routers/org/home.go
+++ b/routers/org/home.go
@@ -85,7 +85,6 @@ func Home(ctx *context.Context) {
OrderBy: orderBy,
Private: ctx.IsSigned,
Actor: ctx.User,
- IsProfile: true,
IncludeDescription: setting.UI.SearchRepoDescription,
})
if err != nil {
diff --git a/routers/repo/view.go b/routers/repo/view.go
index f56c524359..9183aea030 100644
--- a/routers/repo/view.go
+++ b/routers/repo/view.go
@@ -457,6 +457,16 @@ func Home(ctx *context.Context) {
ctx.NotFound("Home", fmt.Errorf(ctx.Tr("units.error.no_unit_allowed_repo")))
}
+func renderLanguageStats(ctx *context.Context) {
+ langs, err := ctx.Repo.Repository.GetTopLanguageStats(5)
+ if err != nil {
+ ctx.ServerError("Repo.GetTopLanguageStats", err)
+ return
+ }
+
+ ctx.Data["LanguageStats"] = langs
+}
+
func renderCode(ctx *context.Context) {
ctx.Data["PageIsViewCode"] = true
@@ -497,6 +507,11 @@ func renderCode(ctx *context.Context) {
return
}
+ renderLanguageStats(ctx)
+ if ctx.Written() {
+ return
+ }
+
if entry.IsDir() {
renderDirectory(ctx, treeLink)
} else {
diff --git a/routers/user/profile.go b/routers/user/profile.go
index a151884d76..215dff0084 100644
--- a/routers/user/profile.go
+++ b/routers/user/profile.go
@@ -220,7 +220,6 @@ func Profile(ctx *context.Context) {
OwnerID: ctxUser.ID,
OrderBy: orderBy,
Private: ctx.IsSigned,
- IsProfile: true,
Collaborate: util.OptionalBoolFalse,
TopicOnly: topicOnly,
IncludeDescription: setting.UI.SearchRepoDescription,