50 lines
1.0 KiB
Go
Raw Normal View History

2017-10-06 20:07:12 +00:00
package editor
import (
"github.com/aerogo/aero"
2018-03-09 21:33:08 +00:00
"github.com/animenotifier/arn"
2017-10-06 20:07:12 +00:00
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get ...
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil || (user.Role != "admin" && user.Role != "editor") {
return ctx.Redirect("/")
}
2018-03-10 00:20:54 +00:00
ignoreDifferences := arn.FilterIgnoreAnimeDifferences(func(entry *arn.IgnoreAnimeDifference) bool {
return entry.CreatedBy == user.ID
})
2018-03-09 21:33:08 +00:00
logEntries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
return entry.UserID == user.ID
})
2018-03-10 00:20:54 +00:00
score := len(ignoreDifferences)
2018-03-09 21:33:08 +00:00
for _, entry := range logEntries {
switch entry.Action {
case "create":
score += 10
case "edit":
score += 2
2018-03-10 00:20:54 +00:00
if entry.ObjectType == "Anime" && (entry.Key == "Summary" || entry.Key == "Synopsis") {
score += 2
}
2018-03-09 21:33:08 +00:00
case "delete", "arrayRemove":
score++
case "arrayAppend":
// No score
}
}
return ctx.HTML(components.Editor(ctx.URI(), score, user))
2017-10-06 20:07:12 +00:00
}