summaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-10-16 00:54:53 +0300
committerGitHub <noreply@github.com>2017-10-16 00:54:53 +0300
commitc7f4f07765a96ac4b66f40167ed4207aa4e34dad (patch)
treee476f019eb40cd61de15398ef3c928606b5dda5d /routers/repo
parentf3833b7ce4dc78095194808c6e07d8ae133e7ab5 (diff)
downloadgitea-c7f4f07765a96ac4b66f40167ed4207aa4e34dad.tar.gz
gitea-c7f4f07765a96ac4b66f40167ed4207aa4e34dad.zip
Integration test for activity page (#2704)
* Integration test for activity page * Small code refactoring for acitvity page * Move activity stats calculation logic to model
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/activity.go28
1 files changed, 4 insertions, 24 deletions
diff --git a/routers/repo/activity.go b/routers/repo/activity.go
index 564537c1fd..fbe51e152e 100644
--- a/routers/repo/activity.go
+++ b/routers/repo/activity.go
@@ -43,34 +43,14 @@ func Activity(ctx *context.Context) {
ctx.Data["DateUntil"] = timeUntil.Format("January 2, 2006")
ctx.Data["PeriodText"] = ctx.Tr("repo.activity.period." + ctx.Data["Period"].(string))
- stats := &models.ActivityStats{}
-
- if ctx.Repo.Repository.UnitEnabled(models.UnitTypeReleases) {
- if err := models.FillReleasesForActivity(stats, ctx.Repo.Repository.ID, timeFrom); err != nil {
- ctx.Handle(500, "FillReleasesForActivity", err)
- return
- }
- }
- if ctx.Repo.Repository.UnitEnabled(models.UnitTypePullRequests) {
- if err := models.FillPullRequestsForActivity(stats, ctx.Repo.Repository.ID, timeFrom); err != nil {
- ctx.Handle(500, "FillPullRequestsForActivity", err)
- return
- }
- }
- if ctx.Repo.Repository.UnitEnabled(models.UnitTypeIssues) {
- if err := models.FillIssuesForActivity(stats, ctx.Repo.Repository.ID, timeFrom); err != nil {
- ctx.Handle(500, "FillIssuesForActivity", err)
- return
- }
- }
- if err := models.FillUnresolvedIssuesForActivity(stats, ctx.Repo.Repository.ID, timeFrom,
+ var err error
+ if ctx.Data["Activity"], err = models.GetActivityStats(ctx.Repo.Repository.ID, timeFrom,
+ ctx.Repo.Repository.UnitEnabled(models.UnitTypeReleases),
ctx.Repo.Repository.UnitEnabled(models.UnitTypeIssues),
ctx.Repo.Repository.UnitEnabled(models.UnitTypePullRequests)); err != nil {
- ctx.Handle(500, "FillUnresolvedIssuesForActivity", err)
+ ctx.Handle(500, "GetActivityStats", err)
return
}
- ctx.Data["Activity"] = stats
-
ctx.HTML(200, tplActivity)
}