switch to slice of pointers for sorting purposes

master
nate smith 2019-09-10 16:19:40 -05:00
parent 2aa5fb9f55
commit 623d411b88
1 changed files with 11 additions and 11 deletions

View File

@ -53,7 +53,7 @@ type tildeData struct {
AdminEmail string `json:"admin_email"` // Email for server admin AdminEmail string `json:"admin_email"` // Email for server admin
Description string `json:"description"` // Description of server Description string `json:"description"` // Description of server
UserCount int `json:"user_count"` // Total number of users on server sorted by last activity time UserCount int `json:"user_count"` // Total number of users on server sorted by last activity time
Users []user `json:"users"` Users []*user `json:"users"`
// Town Additions // Town Additions
LiveUserCount int `json:"live_user_count"` // Users who have changed their index.html LiveUserCount int `json:"live_user_count"` // Users who have changed their index.html
ActiveUserCount int `json:"active_user_count"` // Users with an active session ActiveUserCount int `json:"active_user_count"` // Users with an active session
@ -237,7 +237,7 @@ func getDefaultHTML() ([]byte, error) {
type usersByMtime []*user type usersByMtime []*user
func getUsers() (users []user, err error) { func getUsers() (users []*user, err error) {
// TODO sort by mtime // TODO sort by mtime
// For the purposes of this program, we discover users via: // For the purposes of this program, we discover users via:
// - presence in /home/ // - presence in /home/
@ -270,13 +270,13 @@ func getUsers() (users []user, err error) {
Mtime: mtimeFor(username), Mtime: mtimeFor(username),
DefaultPage: detectDefaultPageFor(username, defaultIndexHTML), DefaultPage: detectDefaultPageFor(username, defaultIndexHTML),
} }
users = append(users, user) users = append(users, &user)
} }
return users, nil return users, nil
} }
func liveUserCount(users []user) int { func liveUserCount(users []*user) int {
count := 0 count := 0
for _, u := range users { for _, u := range users {
if !u.DefaultPage { if !u.DefaultPage {