diff --git a/resources/views/servidor_dashboard.html b/resources/views/servidor_dashboard.html
index 3697cad..34b35f6 100644
--- a/resources/views/servidor_dashboard.html
+++ b/resources/views/servidor_dashboard.html
@@ -77,7 +77,7 @@
-
+
conexiones BD
diff --git a/rest/controllers/servidor_controller.go b/rest/controllers/servidor_controller.go
index 8416a38..3e55cd9 100755
--- a/rest/controllers/servidor_controller.go
+++ b/rest/controllers/servidor_controller.go
@@ -63,9 +63,42 @@ func GetServidor(c *fiber.Ctx) error {
"error": err.Error(),
})
}
+
+ // Build connection count map per server
+ type conxCount struct {
+ ServidorID uint `gorm:"column:servidor_id"`
+ Count int64 `gorm:"column:count"`
+ }
+ var counts []conxCount
+ serverIDs := make([]uint, len(records))
+ for i, s := range records {
+ serverIDs[i] = s.ID
+ }
+ if len(serverIDs) > 0 {
+ app.Http.Database.DB.Table("conx_db").
+ Select("servidor_id, count(*) as count").
+ Where("servidor_id IN ? AND deleted_at IS NULL", serverIDs).
+ Group("servidor_id").
+ Scan(&counts)
+ }
+ countMap := make(map[uint]int64)
+ for _, cc := range counts {
+ countMap[cc.ServidorID] = cc.Count
+ }
+
+ // Attach conx_count to each record
+ type servidorWithCount struct {
+ models.Servidor
+ ConxCount int64 `json:"conx_count"`
+ }
+ enriched := make([]servidorWithCount, len(records))
+ for i, s := range records {
+ enriched[i] = servidorWithCount{Servidor: s, ConxCount: countMap[s.ID]}
+ }
+
totalPages := int(math.Ceil(float64(total) / float64(limit)))
return c.JSON(fiber.Map{
- "registros": records,
+ "registros": enriched,
"total": total,
"totalPages": totalPages,
"page": page,