Skip to content

Commit

Permalink
fix the userStats calculation on BE for users page
Browse files Browse the repository at this point in the history
  • Loading branch information
krustowski committed Jul 16, 2024
1 parent 18db838 commit aee9f56
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#

APP_NAME=litter-go
APP_VERSION=0.35.19
APP_VERSION=0.35.20
GOLANG_VERSION=1.22
2 changes: 1 addition & 1 deletion api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "MIT",
"url": "https://github.com/krustowski/litter-go/blob/master/LICENSE"
},
"version": "0.35.19"
"version": "0.35.20"
},
"host": "littr.eu",
"basePath": "/api/v1",
Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/router.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @title litter-go
// @version 0.35.19
// @version 0.35.20
// @description nanoblogging platform as PWA built on go-app framework
// @termsOfService https://littr.eu/tos

Expand Down
31 changes: 16 additions & 15 deletions pkg/backend/users/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,6 @@ func getUsers(w http.ResponseWriter, r *http.Request) {
posts, _ := db.GetAll(db.FlowCache, models.Post{})
devs, _ := db.GetOne(db.SubscriptionCache, caller, []models.Device{})

// flush email addresses
for key, user := range users {
user.Passphrase = ""
user.PassphraseHex = ""
user.Email = ""

if user.Nickname != caller {
user.FlowList = nil
user.ShadeList = nil
user.RequestList = nil
}

users[key] = user
}

// check the subscription
//devSubscribed := false
var devTags []string = nil
Expand Down Expand Up @@ -92,6 +77,7 @@ func getUsers(w http.ResponseWriter, r *http.Request) {
stats[nick] = stat
}

// calculate the users stats
for nick, user := range users {
flowList := user.FlowList
if flowList == nil {
Expand All @@ -107,6 +93,21 @@ func getUsers(w http.ResponseWriter, r *http.Request) {
}
}

// flush unwanted properties
for key, user := range users {
user.Passphrase = ""
user.PassphraseHex = ""
user.Email = ""

if user.Nickname != caller {
user.FlowList = nil
user.ShadeList = nil
user.RequestList = nil
}

users[key] = user
}

resp.Message = "ok, dumping users"
resp.Code = http.StatusOK
resp.Users = users
Expand Down

0 comments on commit aee9f56

Please sign in to comment.