Improved registrations page

This commit is contained in:
Eduard Urbach 2018-04-16 15:21:42 +02:00
parent 802273b7c3
commit 39ef07307c
2 changed files with 6 additions and 3 deletions

View File

@ -23,6 +23,7 @@ func UserRegistrations(ctx *aero.Context) string {
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil) return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
} }
total := 0
yearInfo := map[int]utils.YearRegistrations{} yearInfo := map[int]utils.YearRegistrations{}
years := []int{} years := []int{}
@ -44,6 +45,8 @@ func UserRegistrations(ctx *aero.Context) string {
yearRegistrations.Months[int(registered.Month())]++ yearRegistrations.Months[int(registered.Month())]++
yearInfo[year] = yearRegistrations yearInfo[year] = yearRegistrations
total++
} }
for year := range yearInfo { for year := range yearInfo {
@ -52,5 +55,5 @@ func UserRegistrations(ctx *aero.Context) string {
sort.Ints(years) sort.Ints(years)
return ctx.HTML(components.UserRegistrations(years, yearInfo)) return ctx.HTML(components.UserRegistrations(total, years, yearInfo))
} }

View File

@ -1,6 +1,6 @@
component UserRegistrations(years []int, yearInfo map[int]utils.YearRegistrations) component UserRegistrations(total int, years []int, yearInfo map[int]utils.YearRegistrations)
AdminTabs AdminTabs
h1.page-title User registrations h1.mountable= fmt.Sprintf("User registrations (%d)", total)
for _, year := range years for _, year := range years
h3.mountable= year h3.mountable= year