models.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package search
  2. import "strings"
  3. type HitType string
  4. const (
  5. DashHitDB HitType = "dash-db"
  6. DashHitHome HitType = "dash-home"
  7. DashHitJson HitType = "dash-json"
  8. DashHitScripted HitType = "dash-scripted"
  9. DashHitFolder HitType = "dash-folder"
  10. )
  11. type Hit struct {
  12. Id int64 `json:"id"`
  13. Title string `json:"title"`
  14. Uri string `json:"uri"`
  15. Type HitType `json:"type"`
  16. Tags []string `json:"tags"`
  17. IsStarred bool `json:"isStarred"`
  18. ParentId int64 `json:"parentId"`
  19. Dashboards []Hit `json:"dashboards"`
  20. }
  21. type HitList []*Hit
  22. func (s HitList) Len() int { return len(s) }
  23. func (s HitList) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
  24. func (s HitList) Less(i, j int) bool {
  25. if s[i].Type == "dash-folder" && s[j].Type == "dash-db" {
  26. return true
  27. }
  28. if s[i].Type == "dash-db" && s[j].Type == "dash-folder" {
  29. return false
  30. }
  31. return strings.ToLower(s[i].Title) < strings.ToLower(s[j].Title)
  32. }
  33. type Query struct {
  34. Title string
  35. Tags []string
  36. OrgId int64
  37. UserId int64
  38. Limit int
  39. IsStarred bool
  40. Type string
  41. DashboardIds []int
  42. FolderId int64
  43. Mode string
  44. Result HitList
  45. }
  46. type FindPersistedDashboardsQuery struct {
  47. Title string
  48. OrgId int64
  49. UserId int64
  50. IsStarred bool
  51. DashboardIds []int
  52. Type string
  53. ParentId int64
  54. Mode string
  55. Result HitList
  56. }