mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user