all repos — flounder @ 2d17a0055fd7f6473b133d6c9ddd924ea8c189af

A small site builder for the Gemini protocol

list users in a sorted order
alex wennerberg alex@alexwennerberg.com
Fri, 01 Jan 2021 12:06:17 -0800
commit

2d17a0055fd7f6473b133d6c9ddd924ea8c189af

parent

8640ccd33f3035b892c74662f4907e1dc5a83ae8

1 files changed, 2 insertions(+), 9 deletions(-)

jump to
M db.godb.go

@@ -6,7 +6,6 @@ "database/sql"

"io" "io/ioutil" "log" - mathrand "math/rand" "os" "path" "path/filepath"

@@ -60,9 +59,8 @@ CreatedAt int // timestamp

Reference string } -// returns in a random order func getActiveUserNames() ([]string, error) { - rows, err := DB.Query(`SELECT username from user WHERE active is true`) + rows, err := DB.Query(`SELECT username from user WHERE active is true order by username`) if err != nil { return nil, err }

@@ -76,12 +74,7 @@ }

users = append(users, user) } - dest := make([]string, len(users)) - perm := mathrand.Perm(len(users)) - for i, v := range perm { - dest[v] = users[i] - } - return dest, nil + return users, nil } func getUserByName(username string) (*User, error) {