ops_summary_service.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package service
  2. import (
  3. "context"
  4. "cmr-backend/internal/store/postgres"
  5. )
  6. type OpsOverviewSummary struct {
  7. ManagedAssets int `json:"managedAssets"`
  8. Places int `json:"places"`
  9. MapAssets int `json:"mapAssets"`
  10. TileReleases int `json:"tileReleases"`
  11. CourseSets int `json:"courseSets"`
  12. CourseVariants int `json:"courseVariants"`
  13. Events int `json:"events"`
  14. DefaultEvents int `json:"defaultEvents"`
  15. PublishedEvents int `json:"publishedEvents"`
  16. ConfigSources int `json:"configSources"`
  17. Releases int `json:"releases"`
  18. RuntimeBindings int `json:"runtimeBindings"`
  19. Presentations int `json:"presentations"`
  20. ContentBundles int `json:"contentBundles"`
  21. OpsUsers int `json:"opsUsers"`
  22. }
  23. type OpsSummaryService struct {
  24. store *postgres.Store
  25. }
  26. func NewOpsSummaryService(store *postgres.Store) *OpsSummaryService {
  27. return &OpsSummaryService{store: store}
  28. }
  29. func (s *OpsSummaryService) GetOverview(ctx context.Context) (*OpsOverviewSummary, error) {
  30. counts, err := s.store.GetOpsOverviewCounts(ctx)
  31. if err != nil {
  32. return nil, err
  33. }
  34. return &OpsOverviewSummary{
  35. ManagedAssets: counts.ManagedAssets,
  36. Places: counts.Places,
  37. MapAssets: counts.MapAssets,
  38. TileReleases: counts.TileReleases,
  39. CourseSets: counts.CourseSets,
  40. CourseVariants: counts.CourseVariants,
  41. Events: counts.Events,
  42. DefaultEvents: counts.DefaultEvents,
  43. PublishedEvents: counts.PublishedEvents,
  44. ConfigSources: counts.ConfigSources,
  45. Releases: counts.Releases,
  46. RuntimeBindings: counts.RuntimeBindings,
  47. Presentations: counts.Presentations,
  48. ContentBundles: counts.ContentBundles,
  49. OpsUsers: counts.OpsUsers,
  50. }, nil
  51. }