stufflog graphql server
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.

40 lines
855 B

  1. package models
  2. // A Project is a vague category for issues. It's use depend on the user's judgement, as it could represent
  3. // an entire hobby/job or a single project within one.
  4. type Project struct {
  5. ID string `db:"project_id"`
  6. Name string `db:"name"`
  7. Description string `db:"description"`
  8. DailyPoints int `db:"daily_points"`
  9. }
  10. type ProjectFilter struct {
  11. ProjectIDs []string
  12. Search *string
  13. Permission *ProjectFilterPermission
  14. }
  15. type ProjectFilterPermission struct {
  16. UserID string
  17. MinLevel int
  18. MaxLevel int
  19. }
  20. func (project *Project) ValidKey() bool {
  21. if len(project.ID) < 1 || len(project.ID) > 16 {
  22. return false
  23. }
  24. for _, r := range project.ID {
  25. if r < 'A' && r > 'Z' {
  26. return false
  27. }
  28. }
  29. return true
  30. }
  31. func (pfp *ProjectFilterPermission) Valid() bool {
  32. return pfp.UserID != "" && pfp.MinLevel > 0
  33. }