2022-12-02 20:40:58 -07:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
2023-01-10 20:23:47 -07:00
|
|
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg"
|
2022-12-02 20:40:58 -07:00
|
|
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetSummary(c *gin.Context) {
|
2023-01-10 20:23:47 -07:00
|
|
|
logger := c.MustGet(pkg.ContextKeyTypeLogger).(*logrus.Entry)
|
|
|
|
databaseRepo := c.MustGet(pkg.ContextKeyTypeDatabase).(database.DatabaseRepository)
|
2022-12-02 20:40:58 -07:00
|
|
|
|
|
|
|
summary, err := databaseRepo.GetSummary(c)
|
|
|
|
if err != nil {
|
|
|
|
logger.Errorln("An error occurred while retrieving summary", err)
|
|
|
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{"success": true, "data": summary})
|
|
|
|
}
|