diff options
author | Lauris BH <lauris@nix.lv> | 2017-10-16 00:54:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-16 00:54:53 +0300 |
commit | c7f4f07765a96ac4b66f40167ed4207aa4e34dad (patch) | |
tree | e476f019eb40cd61de15398ef3c928606b5dda5d /routers/repo | |
parent | f3833b7ce4dc78095194808c6e07d8ae133e7ab5 (diff) | |
download | gitea-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.go | 28 |
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) } |