diff --git a/pages/editor/editor.go b/pages/editor/editor.go index 1db2d741..851f0c9c 100644 --- a/pages/editor/editor.go +++ b/pages/editor/editor.go @@ -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,25 @@ func Get(ctx *aero.Context) string { return ctx.Redirect("/") } - return ctx.HTML(components.Editor(ctx.URI(), user.EditorScore(), user)) + ignoreDifferences := arn.FilterIgnoreAnimeDifferences(func(entry *arn.IgnoreAnimeDifference) bool { + return entry.CreatedBy == user.ID + }) + + score := len(ignoreDifferences) * arn.IgnoreAnimeDifferenceEditorScore + scoreTypes := map[string]int{} + + logEntries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool { + return entry.UserID == user.ID + }) + + for _, entry := range logEntries { + entryScore := entry.EditorScore() + score += entryScore + + if entry.ObjectType != "" { + scoreTypes[entry.ObjectType]++ + } + } + + return ctx.HTML(components.Editor(ctx.URI(), score, scoreTypes, user)) } diff --git a/pages/editor/editor.pixy b/pages/editor/editor.pixy index 35e87d2e..13c21d83 100644 --- a/pages/editor/editor.pixy +++ b/pages/editor/editor.pixy @@ -1,12 +1,17 @@ -component Editor(url string, score int, user *arn.User) +component Editor(url string, score int, scoreTypes map[string]int, user *arn.User) EditorTabs(url) h1.mountable= "Welcome to the Editor Panel, " + user.Nick + "!" .feature-cards .feature-card.mountable .feature-card-icon.editor-score= score - p.feature-card-text Your contribution score. + + .feature-cards.feature-cards-alternative-color + for objectType, score := range scoreTypes + .feature-card.mountable + .feature-card-icon.editor-score= score + p.feature-card-text= objectType component EditorTabs(url string) .tabs