New editor score system and new user lists

This commit is contained in:
Eduard Urbach 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 ( import (
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils" "github.com/animenotifier/notify.moe/utils"
) )
@ -15,35 +14,5 @@ func Get(ctx *aero.Context) string {
return ctx.Redirect("/") return ctx.Redirect("/")
} }
ignoreDifferences := arn.FilterIgnoreAnimeDifferences(func(entry *arn.IgnoreAnimeDifference) bool { return ctx.HTML(components.Editor(ctx.URI(), user.EditorScore(), user))
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))
} }

View File

@ -88,9 +88,11 @@ func Configure(app *aero.Application) {
// User lists // User lists
l.Page("/users", users.Active) l.Page("/users", users.Active)
l.Page("/users/noavatar", users.ActiveNoAvatar) l.Page("/users/noavatar", users.ActiveNoAvatar)
l.Page("/users/osu", users.Osu) l.Page("/users/games/osu", users.Osu)
l.Page("/users/overwatch", users.Overwatch) l.Page("/users/games/overwatch", users.Overwatch)
l.Page("/users/staff", users.Staff) l.Page("/users/staff", users.Staff)
l.Page("/users/pro", users.Pro)
l.Page("/users/editors", users.Editors)
// Statistics // Statistics
l.Page("/statistics", statistics.Get) l.Page("/statistics", statistics.Get)

View File

@ -114,7 +114,7 @@ profile-boot-duration = 2s
.profile-image .profile-image
object-fit cover object-fit cover
width 100% width 100%
height auto height 100%
.profile-image-container .profile-image-container
flex 1 flex 1

21
pages/users/editors.pixy Normal file
View File

@ -0,0 +1,21 @@
component EditorRankingList(users []*arn.User, url string)
h1.page-title Editor ranking list
UsersTabs(url)
table.ranking-list
thead
tr.mountable
th #
th User
th.ranking-score Score
tbody
for index, user := range users
tr.ranking.mountable
td= toString(index + 1) + "."
td.ranking-user
Avatar(user)
a.ajax(href=user.Link())= user.Nick
td.ranking-score= user.EditorScore()
.footer.mountable
p Score is generated from new data submissions and data fixes.

View File

@ -1,7 +1,6 @@
component OsuRankingList(users []*arn.User) component OsuRankingList(users []*arn.User, url string)
h1.page-title osu! ranking list h1.page-title osu! ranking list
UsersTabs(url)
UsersTabs
table.ranking-list table.ranking-list
thead thead

View File

@ -1,7 +1,6 @@
component OverwatchRankingList(users []*arn.User) component OverwatchRankingList(users []*arn.User, url string)
h1.page-title Overwatch ranking list h1.page-title Overwatch ranking list
UsersTabs(url)
UsersTabs
table.ranking-list table.ranking-list
thead thead

View File

@ -36,7 +36,55 @@ func Active(ctx *aero.Context) string {
return followersA > followersB return followersA > followersB
}) })
return ctx.HTML(components.Users(users)) return ctx.HTML(components.Users(users, ctx.URI()))
}
// Pro ...
func Pro(ctx *aero.Context) string {
users := arn.FilterUsers(func(user *arn.User) bool {
return user.IsPro()
})
sort.Slice(users, func(i, j int) bool {
return users[i].Registered > users[j].Registered
})
return ctx.HTML(components.ProUsers(users, ctx.URI()))
}
// Editors ...
func Editors(ctx *aero.Context) string {
score := map[string]int{}
users := []*arn.User{}
for entry := range arn.StreamEditLogEntries() {
entryScore := entry.EditorScore()
if entryScore == 0 {
continue
}
current, exists := score[entry.UserID]
if !exists {
users = append(users, entry.User())
}
score[entry.UserID] = current + entryScore
}
sort.Slice(users, func(i, j int) bool {
scoreA := score[users[i].ID]
scoreB := score[users[j].ID]
if scoreA == scoreB {
return users[i].Registered > users[j].Registered
}
return scoreA > scoreB
})
return ctx.HTML(components.EditorRankingList(users, ctx.URI()))
} }
// ActiveNoAvatar ... // ActiveNoAvatar ...
@ -66,7 +114,7 @@ func ActiveNoAvatar(ctx *aero.Context) string {
return followersA > followersB return followersA > followersB
}) })
return ctx.HTML(components.Users(users)) return ctx.HTML(components.Users(users, ctx.URI()))
} }
// Osu ... // Osu ...
@ -84,7 +132,7 @@ func Osu(ctx *aero.Context) string {
users = users[:50] users = users[:50]
} }
return ctx.HTML(components.OsuRankingList(users)) return ctx.HTML(components.OsuRankingList(users, ctx.URI()))
} }
// Overwatch ... // Overwatch ...
@ -102,7 +150,7 @@ func Overwatch(ctx *aero.Context) string {
users = users[:50] users = users[:50]
} }
return ctx.HTML(components.OverwatchRankingList(users)) return ctx.HTML(components.OverwatchRankingList(users, ctx.URI()))
} }
// Staff ... // Staff ...
@ -156,5 +204,5 @@ func Staff(ctx *aero.Context) string {
editors, editors,
} }
return ctx.HTML(components.UserLists(userLists) + components.StaffRecruitment()) return ctx.HTML(components.UserLists(userLists, ctx.URI()) + components.StaffRecruitment())
} }

View File

@ -1,17 +1,29 @@
component Users(users []*arn.User) component Users(users []*arn.User, url string)
h1.page-title Users h1.page-title Users
UsersTabs(url)
UsersTabs
.user-avatars .user-avatars
each user in users each user in users
.mountable .mountable
Avatar(user) Avatar(user)
component UserLists(groups []*utils.UserList) component ProUsers(users []*arn.User, url string)
h1.page-title Users h1.page-title Supporters
UsersTabs(url)
UsersTabs .pro-avatars
each user in users
a.profile-image-container.mountable.ajax(href=user.Link())
ProfileImage(user)
.anime-grid-title
.anime-grid-title-text= user.Nick
.footer.mountable
p We are thankful to everyone supporting the site!
component UserLists(groups []*utils.UserList, url string)
h1.page-title Users
UsersTabs(url)
each group in groups each group in groups
h3.user-list-name.mountable= group.Name h3.user-list-name.mountable= group.Name
@ -28,10 +40,15 @@ component StaffRecruitment
br br
a(href="https://discord.gg/0kimAmMCeXGXuzNF", target="_blank", rel="noopener") Interested in editing data? a(href="https://discord.gg/0kimAmMCeXGXuzNF", target="_blank", rel="noopener") Interested in editing data?
component UsersTabs component UsersTabs(url string)
.tabs .tabs
Tab("Active", "users", "/users") Tab("Active", "users", "/users")
//- Tab("No Avatar", "users", "/users/noavatar") Tab("Games", "gamepad", "/users/games/osu")
Tab("Osu", "gamepad", "/users/osu") Tab("Editors", "pencil", "/users/editors")
Tab("Overwatch", "overwatch", "/users/overwatch") Tab("Supporters", "heart", "/users/pro")
Tab("Staff", "user-secret", "/users/staff") Tab("Staff", "user-secret", "/users/staff")
if strings.Contains(url, "/users/games")
.tabs
Tab("Osu", "gamepad", "/users/games/osu")
Tab("Overwatch", "overwatch", "/users/games/overwatch")

View File

@ -6,6 +6,24 @@
.user-image .user-image
margin 0.4rem margin 0.4rem
.pro-avatars
horizontal-wrap
justify-content center
.profile-image-container
width 140px
height 140px
max-width 140px
max-height 140px
margin 0.4rem
position relative
border ui-border
box-shadow shadow-light
:hover
.anime-grid-title
opacity 1
.user .user
display flex display flex

View File

@ -10,6 +10,9 @@ export function save(arn: AnimeNotifier, input: HTMLElement) {
return return
} }
// Trim value
value = value.trim()
if((input as HTMLInputElement).type === "number" || input.dataset.type === "number") { if((input as HTMLInputElement).type === "number" || input.dataset.type === "number") {
if(input.getAttribute("step") === "1" || input.dataset.step === "1") { if(input.getAttribute("step") === "1" || input.dataset.step === "1") {
obj[input.dataset.field] = parseInt(value) obj[input.dataset.field] = parseInt(value)