RoadSign/pkg/sideload/statistics.go

28 lines
784 B
Go
Raw Normal View History

2024-01-01 10:07:21 +00:00
package sideload
import (
2024-01-24 16:09:39 +00:00
"code.smartsheep.studio/goatworks/roadsign/pkg/navi"
"code.smartsheep.studio/goatworks/roadsign/pkg/warden"
2024-01-01 10:07:21 +00:00
"github.com/gofiber/fiber/v2"
"github.com/samber/lo"
)
func getStatistics(c *fiber.Ctx) error {
2024-01-24 16:09:39 +00:00
locations := lo.FlatMap(navi.R.Regions, func(item *navi.Region, idx int) []navi.Location {
return item.Locations
2024-01-01 10:07:21 +00:00
})
2024-01-24 16:09:39 +00:00
destinations := lo.FlatMap(locations, func(item navi.Location, idx int) []navi.Destination {
return item.Destinations
2024-01-01 10:07:21 +00:00
})
2024-01-24 16:09:39 +00:00
applications := lo.FlatMap(navi.R.Regions, func(item *navi.Region, idx int) []warden.Application {
return item.Applications
2024-01-01 10:07:21 +00:00
})
return c.JSON(fiber.Map{
2024-01-24 16:09:39 +00:00
"regions": len(navi.R.Regions),
"locations": len(locations),
"destinations": len(destinations),
"applications": len(applications),
2024-01-01 10:07:21 +00:00
})
}