Add additional periods to activity page (#8829)

pull/8815/head^2
Lauris BH 5 years ago committed by techknowlogick
parent 8d8aecd3cf
commit a91679c9e3
  1. 3
      options/locale/locale_en-US.ini
  2. 12
      routers/repo/activity.go
  3. 3
      templates/repo/activity.tmpl

@ -1090,6 +1090,9 @@ activity.period.daily = 1 day
activity.period.halfweekly = 3 days activity.period.halfweekly = 3 days
activity.period.weekly = 1 week activity.period.weekly = 1 week
activity.period.monthly = 1 month activity.period.monthly = 1 month
activity.period.quarterly = 3 months
activity.period.semiyearly = 6 months
activity.period.yearly = 1 year
activity.overview = Overview activity.overview = Overview
activity.active_prs_count_1 = <strong>%d</strong> Active Pull Request activity.active_prs_count_1 = <strong>%d</strong> Active Pull Request
activity.active_prs_count_n = <strong>%d</strong> Active Pull Requests activity.active_prs_count_n = <strong>%d</strong> Active Pull Requests

@ -35,6 +35,12 @@ func Activity(ctx *context.Context) {
timeFrom = timeUntil.Add(-time.Hour * 168) timeFrom = timeUntil.Add(-time.Hour * 168)
case "monthly": case "monthly":
timeFrom = timeUntil.AddDate(0, -1, 0) 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: default:
ctx.Data["Period"] = "weekly" ctx.Data["Period"] = "weekly"
timeFrom = timeUntil.Add(-time.Hour * 168) timeFrom = timeUntil.Add(-time.Hour * 168)
@ -70,6 +76,12 @@ func ActivityAuthors(ctx *context.Context) {
timeFrom = timeUntil.Add(-time.Hour * 168) timeFrom = timeUntil.Add(-time.Hour * 168)
case "monthly": case "monthly":
timeFrom = timeUntil.AddDate(0, -1, 0) 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: default:
timeFrom = timeUntil.Add(-time.Hour * 168) timeFrom = timeUntil.Add(-time.Hour * 168)
} }

@ -17,6 +17,9 @@
<a class="{{if eq .Period "halfweekly"}}active {{end}}item" href="{{$.RepoLink}}/activity/halfweekly">{{.i18n.Tr "repo.activity.period.halfweekly"}}</a> <a class="{{if eq .Period "halfweekly"}}active {{end}}item" href="{{$.RepoLink}}/activity/halfweekly">{{.i18n.Tr "repo.activity.period.halfweekly"}}</a>
<a class="{{if eq .Period "weekly"}}active {{end}}item" href="{{$.RepoLink}}/activity/weekly">{{.i18n.Tr "repo.activity.period.weekly"}}</a> <a class="{{if eq .Period "weekly"}}active {{end}}item" href="{{$.RepoLink}}/activity/weekly">{{.i18n.Tr "repo.activity.period.weekly"}}</a>
<a class="{{if eq .Period "monthly"}}active {{end}}item" href="{{$.RepoLink}}/activity/monthly">{{.i18n.Tr "repo.activity.period.monthly"}}</a> <a class="{{if eq .Period "monthly"}}active {{end}}item" href="{{$.RepoLink}}/activity/monthly">{{.i18n.Tr "repo.activity.period.monthly"}}</a>
<a class="{{if eq .Period "quarterly"}}active {{end}}item" href="{{$.RepoLink}}/activity/quarterly">{{.i18n.Tr "repo.activity.period.quarterly"}}</a>
<a class="{{if eq .Period "semiyearly"}}active {{end}}item" href="{{$.RepoLink}}/activity/semiyearly">{{.i18n.Tr "repo.activity.period.semiyearly"}}</a>
<a class="{{if eq .Period "yearly"}}active {{end}}item" href="{{$.RepoLink}}/activity/yearly">{{.i18n.Tr "repo.activity.period.yearly"}}</a>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save