2022-04-03 23:24:40 +08:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/jmoiron/sqlx/types"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetDashboardCharts returns chart data points to render on the dashboard.
|
|
|
|
func (c *Core) GetDashboardCharts() (types.JSONText, error) {
|
2024-01-12 00:53:39 +08:00
|
|
|
_ = c.refreshCache(matDashboardCharts, false)
|
|
|
|
|
2022-04-03 23:24:40 +08:00
|
|
|
var out types.JSONText
|
|
|
|
if err := c.q.GetDashboardCharts.Get(&out); err != nil {
|
|
|
|
return nil, echo.NewHTTPError(http.StatusInternalServerError,
|
|
|
|
c.i18n.Ts("globals.messages.errorFetching", "name", "dashboard charts", "error", pqErrMsg(err)))
|
|
|
|
}
|
|
|
|
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetDashboardCounts returns stats counts to show on the dashboard.
|
|
|
|
func (c *Core) GetDashboardCounts() (types.JSONText, error) {
|
2024-01-12 00:53:39 +08:00
|
|
|
_ = c.refreshCache(matDashboardCounts, false)
|
|
|
|
|
2022-04-03 23:24:40 +08:00
|
|
|
var out types.JSONText
|
|
|
|
if err := c.q.GetDashboardCounts.Get(&out); err != nil {
|
|
|
|
return nil, echo.NewHTTPError(http.StatusInternalServerError,
|
|
|
|
c.i18n.Ts("globals.messages.errorFetching", "name", "dashboard stats", "error", pqErrMsg(err)))
|
|
|
|
}
|
|
|
|
|
|
|
|
return out, nil
|
|
|
|
}
|