Skip to content

Commit fbda006

Browse files
committed
Remove duplicated function
1 parent cbf794c commit fbda006

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

routers/web/repo/code_frequency.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ func CodeFrequency(ctx *context.Context) {
2929
ctx.HTML(http.StatusOK, tplCodeFrequency)
3030
}
3131

32-
// CodeFrequencyData returns JSON of code frequency data
33-
func CodeFrequencyData(ctx *context.Context) {
32+
// ContributorStats returns JSON of code contributor stats data
33+
func ContributorStats(ctx *context.Context) {
3434
if contributorStats, err := contributors_service.GetContributorStats(ctx, ctx.Cache, ctx.Repo.Repository, ctx.Repo.Repository.DefaultBranch); err != nil {
3535
if errors.Is(err, contributors_service.ErrAwaitGeneration) {
3636
ctx.Status(http.StatusAccepted)
3737
return
3838
}
39-
ctx.ServerError("GetCodeFrequencyData", err)
39+
ctx.ServerError("ContributorStats", err)
4040
} else {
4141
ctx.JSON(http.StatusOK, contributorStats["total"].Weeks)
4242
}

routers/web/repo/recent_commits.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44
package repo
55

66
import (
7-
"errors"
87
"net/http"
98

109
"code.gitea.io/gitea/models/unit"
1110
"code.gitea.io/gitea/modules/templates"
1211
"code.gitea.io/gitea/services/context"
13-
contributors_service "code.gitea.io/gitea/services/repository"
1412
)
1513

1614
const (
@@ -28,16 +26,3 @@ func RecentCommits(ctx *context.Context) {
2826

2927
ctx.HTML(http.StatusOK, tplRecentCommits)
3028
}
31-
32-
// RecentCommitsData returns JSON of recent commits data
33-
func RecentCommitsData(ctx *context.Context) {
34-
if contributorStats, err := contributors_service.GetContributorStats(ctx, ctx.Cache, ctx.Repo.Repository, ctx.Repo.Repository.DefaultBranch); err != nil {
35-
if errors.Is(err, contributors_service.ErrAwaitGeneration) {
36-
ctx.Status(http.StatusAccepted)
37-
return
38-
}
39-
ctx.ServerError("RecentCommitsData", err)
40-
} else {
41-
ctx.JSON(http.StatusOK, contributorStats["total"].Weeks)
42-
}
43-
}

routers/web/web.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,11 +1484,11 @@ func registerRoutes(m *web.Router) {
14841484
})
14851485
m.Group("/code-frequency", func() {
14861486
m.Get("", repo.CodeFrequency)
1487-
m.Get("/data", repo.CodeFrequencyData)
1487+
m.Get("/data", repo.ContributorStats)
14881488
})
14891489
m.Group("/recent-commits", func() {
14901490
m.Get("", repo.RecentCommits)
1491-
m.Get("/data", repo.RecentCommitsData)
1491+
m.Get("/data", repo.ContributorStats)
14921492
})
14931493
}, reqUnitCodeReader)
14941494
},

0 commit comments

Comments
 (0)