From a91679c9e337c46ab3e441097236f7a4dc07938d Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Tue, 5 Nov 2019 07:45:48 +0200 Subject: [PATCH] Add additional periods to activity page (#8829) --- options/locale/locale_en-US.ini | 3 +++ routers/repo/activity.go | 12 ++++++++++++ templates/repo/activity.tmpl | 3 +++ 3 files changed, 18 insertions(+) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 794d78c6f..db28fcede 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1090,6 +1090,9 @@ activity.period.daily = 1 day activity.period.halfweekly = 3 days activity.period.weekly = 1 week activity.period.monthly = 1 month +activity.period.quarterly = 3 months +activity.period.semiyearly = 6 months +activity.period.yearly = 1 year activity.overview = Overview activity.active_prs_count_1 = %d Active Pull Request activity.active_prs_count_n = %d Active Pull Requests diff --git a/routers/repo/activity.go b/routers/repo/activity.go index e170a9129..0b57d0968 100644 --- a/routers/repo/activity.go +++ b/routers/repo/activity.go @@ -35,6 +35,12 @@ func Activity(ctx *context.Context) { timeFrom = timeUntil.Add(-time.Hour * 168) case "monthly": timeFrom = timeUntil.AddDate(0, -1, 0) + case "quarterly": + timeFrom = timeUntil.AddDate(0, -3, 0) + case "semiyearly": + timeFrom = timeUntil.AddDate(0, -6, 0) + case "yearly": + timeFrom = timeUntil.AddDate(-1, 0, 0) default: ctx.Data["Period"] = "weekly" timeFrom = timeUntil.Add(-time.Hour * 168) @@ -70,6 +76,12 @@ func ActivityAuthors(ctx *context.Context) { timeFrom = timeUntil.Add(-time.Hour * 168) case "monthly": timeFrom = timeUntil.AddDate(0, -1, 0) + case "quarterly": + timeFrom = timeUntil.AddDate(0, -3, 0) + case "semiyearly": + timeFrom = timeUntil.AddDate(0, -6, 0) + case "yearly": + timeFrom = timeUntil.AddDate(-1, 0, 0) default: timeFrom = timeUntil.Add(-time.Hour * 168) } diff --git a/templates/repo/activity.tmpl b/templates/repo/activity.tmpl index 8ee5b5590..504fd3230 100644 --- a/templates/repo/activity.tmpl +++ b/templates/repo/activity.tmpl @@ -17,6 +17,9 @@ {{.i18n.Tr "repo.activity.period.halfweekly"}} {{.i18n.Tr "repo.activity.period.weekly"}} {{.i18n.Tr "repo.activity.period.monthly"}} + {{.i18n.Tr "repo.activity.period.quarterly"}} + {{.i18n.Tr "repo.activity.period.semiyearly"}} + {{.i18n.Tr "repo.activity.period.yearly"}}