New editor score system and new user lists

This commit is contained in:
2018-03-10 16:42:39 +01:00
parent 4d5dd97da4
commit 9958364b92
10 changed files with 133 additions and 57 deletions

View File

@ -2,7 +2,6 @@ package editor
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
@ -15,35 +14,5 @@ func Get(ctx *aero.Context) string {
return ctx.Redirect("/")
}
ignoreDifferences := arn.FilterIgnoreAnimeDifferences(func(entry *arn.IgnoreAnimeDifference) bool {
return entry.CreatedBy == user.ID
})
logEntries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
return entry.UserID == user.ID
})
score := len(ignoreDifferences)
for _, entry := range logEntries {
switch entry.Action {
case "create":
score += 10
case "edit":
score += 2
if entry.ObjectType == "Anime" && (entry.Key == "Summary" || entry.Key == "Synopsis") {
score += 2
}
case "delete", "arrayRemove":
score++
case "arrayAppend":
// No score
}
}
return ctx.HTML(components.Editor(ctx.URI(), score, user))
return ctx.HTML(components.Editor(ctx.URI(), user.EditorScore(), user))
}