switch to slice of pointers for sorting purposes
parent
2aa5fb9f55
commit
623d411b88
8
main.go
8
main.go
|
@ -53,7 +53,7 @@ type tildeData struct {
|
|||
AdminEmail string `json:"admin_email"` // Email for server admin
|
||||
Description string `json:"description"` // Description of server
|
||||
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
|
||||
LiveUserCount int `json:"live_user_count"` // Users who have changed their index.html
|
||||
ActiveUserCount int `json:"active_user_count"` // Users with an active session
|
||||
|
@ -237,7 +237,7 @@ func getDefaultHTML() ([]byte, error) {
|
|||
|
||||
type usersByMtime []*user
|
||||
|
||||
func getUsers() (users []user, err error) {
|
||||
func getUsers() (users []*user, err error) {
|
||||
// TODO sort by mtime
|
||||
// For the purposes of this program, we discover users via:
|
||||
// - presence in /home/
|
||||
|
@ -270,13 +270,13 @@ func getUsers() (users []user, err error) {
|
|||
Mtime: mtimeFor(username),
|
||||
DefaultPage: detectDefaultPageFor(username, defaultIndexHTML),
|
||||
}
|
||||
users = append(users, user)
|
||||
users = append(users, &user)
|
||||
}
|
||||
|
||||
return users, nil
|
||||
}
|
||||
|
||||
func liveUserCount(users []user) int {
|
||||
func liveUserCount(users []*user) int {
|
||||
count := 0
|
||||
for _, u := range users {
|
||||
if !u.DefaultPage {
|
||||
|
|
Loading…
Reference in New Issue