Integration test for activity page (#2704)

* Integration test for activity page

* Small code refactoring for acitvity page

* Move activity stats calculation logic to model
This commit is contained in:
Lauris BH 2017-10-16 00:54:53 +03:00 committed by GitHub
parent f3833b7ce4
commit c7f4f07765
6 changed files with 122 additions and 61 deletions

View file

@ -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)
}