flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 2d17a0055fd7f6473b133d6c9ddd924ea8c189af
parent 8640ccd33f3035b892c74662f4907e1dc5a83ae8
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Fri,  1 Jan 2021 12:06:17 -0800

list users in a sorted order

Diffstat:
Mdb.go | 11++---------
1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/db.go b/db.go @@ -6,7 +6,6 @@ import ( "io" "io/ioutil" "log" - mathrand "math/rand" "os" "path" "path/filepath" @@ -60,9 +59,8 @@ type User struct { 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 @@ func getActiveUserNames() ([]string, error) { 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) {