🗃️ Realm popularity field & sorting communities according to it

This commit is contained in:
LittleSheep 2025-02-20 21:42:19 +08:00
parent a2d033b56c
commit bac655c1cf
2 changed files with 2 additions and 1 deletions

View File

@ -15,6 +15,7 @@ type Realm struct {
Members []RealmMember `json:"members"`
Avatar *string `json:"avatar"`
Banner *string `json:"banner"`
Popularity int `json:"popularity"`
AccessPolicy datatypes.JSONMap `json:"access_policy"`
IsPublic bool `json:"is_public"`
IsCommunity bool `json:"is_community"`

View File

@ -15,7 +15,7 @@ func ListCommunityRealm() ([]models.Realm, error) {
var realms []models.Realm
if err := database.C.Where(&models.Realm{
IsCommunity: true,
}).Find(&realms).Error; err != nil {
}).Order("popularity DESC").Find(&realms).Error; err != nil {
return realms, err
}