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

53 lines
1.0 KiB

  1. package models
  2. type ScopeEntry struct {
  3. ID int `json:"id"`
  4. Name string `json:"name"`
  5. Abbreviation string `json:"abbreviation"`
  6. }
  7. type ScopeMember struct {
  8. ID string `json:"id"`
  9. Name string `json:"name"`
  10. Owner bool `json:"owner"`
  11. }
  12. type Scope struct {
  13. ScopeEntry
  14. DisplayName string `json:"displayName"`
  15. Members []ScopeMember `json:"members"`
  16. Projects []ProjectEntry `json:"projects"`
  17. Stats []Stat `json:"stats"`
  18. StatusLabels map[Status]string `json:"statusLabels"` // Not stored as part of scope, but may be in the future.
  19. }
  20. func (s *Scope) Member(id string) *ScopeMember {
  21. for _, user := range s.Members {
  22. if user.ID == id {
  23. return &user
  24. }
  25. }
  26. return nil
  27. }
  28. func (s *Scope) HasMember(id string) bool {
  29. for _, user := range s.Members {
  30. if user.ID == id {
  31. return true
  32. }
  33. }
  34. return false
  35. }
  36. func (s *Scope) Stat(id int) *Stat {
  37. for _, stat := range s.Stats {
  38. if stat.ID == id {
  39. return &stat
  40. }
  41. }
  42. return nil
  43. }