Improved user sort

This commit is contained in:
Eduard Urbach 2017-06-23 16:53:07 +02:00
parent 8c182f8a4e
commit 8bee2f4e10
2 changed files with 38 additions and 1 deletions

View File

@ -24,7 +24,15 @@ func main() {
// Sort
sort.Slice(users, func(i, j int) bool {
return users[i].LastSeen > users[j].LastSeen
if users[i].LastSeen < users[j].LastSeen {
return false
}
if users[i].LastSeen > users[j].LastSeen {
return true
}
return users[i].Registered > users[j].Registered
})
// Add users to list

View File

@ -0,0 +1,29 @@
package main
import (
"github.com/animenotifier/arn"
)
func main() {
// Get a stream of all users
allUsers, err := arn.AllUsers()
if err != nil {
panic(err)
}
// Iterate over the stream
for user := range allUsers {
if user.LastSeen != "" {
continue
}
user.LastSeen = user.LastLogin
if user.LastSeen == "" {
user.LastSeen = user.Registered
}
user.Save()
}
}