Implemented editor score

This commit is contained in:
2018-03-09 22:33:08 +01:00
parent bf5ee9798b
commit 0127ea0f1c
3 changed files with 35 additions and 11 deletions

View File

@ -2,6 +2,7 @@ package editor
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
@ -14,5 +15,27 @@ func Get(ctx *aero.Context) string {
return ctx.Redirect("/")
}
return ctx.HTML(components.Editor(ctx.URI(), user))
logEntries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
return entry.UserID == user.ID
})
score := 0
for _, entry := range logEntries {
switch entry.Action {
case "create":
score += 10
case "edit":
score += 2
case "delete", "arrayRemove":
score++
case "arrayAppend":
// No score
}
}
return ctx.HTML(components.Editor(ctx.URI(), score, user))
}