Sort public rooms again by member count (#1083)

main
Kegsay 2020-06-02 16:18:01 +01:00 committed by GitHub
parent 02b150fd13
commit e37720be44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import (
"context"
"math/rand"
"net/http"
"sort"
"strconv"
"sync"
"time"
@ -112,6 +113,11 @@ func GetPostPublicRoomsWithExternal(
haveRoomIDs[r.RoomID] = true
publicRooms = append(publicRooms, r)
}
// sort by member count
sort.SliceStable(publicRooms, func(i, j int) bool {
return publicRooms[i].JoinedMembersCount > publicRooms[j].JoinedMembersCount
})
response.Chunk = publicRooms
return util.JSONResponse{