You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cloudbrain_static.go 608 B

3 years ago
12345678910111213141516171819202122
  1. package models
  2. import "code.gitea.io/gitea/modules/log"
  3. func GetAllStatusCloudBrain() map[string]int {
  4. sess := x.NewSession()
  5. defer sess.Close()
  6. cloudbrains := make([]*CloudbrainInfo, 0)
  7. if err := sess.Table(&Cloudbrain{}).Unscoped().
  8. Find(&cloudbrains); err != nil {
  9. log.Info("find error.")
  10. }
  11. cloudBrainStatusResult := make(map[string]int)
  12. for _, cloudbrain := range cloudbrains {
  13. if _, ok := cloudBrainStatusResult[cloudbrain.Status]; !ok {
  14. cloudBrainStatusResult[cloudbrain.Status] = 1
  15. } else {
  16. cloudBrainStatusResult[cloudbrain.Status] += 1
  17. }
  18. }
  19. return cloudBrainStatusResult
  20. }