b5cd9498b1
This is a long pending refactor. All the DB, query, CRUD, and related logic scattered across HTTP handlers are now moved into a central `core` package with clean, abstracted methods, decoupling HTTP handlers from executing direct DB queries and other business logic. eg: `core.CreateList()`, `core.GetLists()` etc. - Remove obsolete subscriber methods. - Move optin hook queries to core. - Move campaign methods to `core`. - Move all campaign methods to `core`. - Move public page functions to `core`. - Move all template functions to `core`. - Move media and settings function to `core`. - Move handler middleware functions to `core`. - Move all bounce functions to `core`. - Move all dashboard functions to `core`. - Fix GetLists() not honouring type - Fix unwrapped JSON responses. - Clean up obsolete pre-core util function. - Replace SQL array null check with cardinality check. - Fix missing validations in `core` queries. - Remove superfluous deps on internal `subimporter`. - Add dashboard functions to `core`. - Fix broken domain ban check. - Fix broken subscriber check middleware. - Remove redundant error handling. - Remove obsolete functions. - Remove obsolete structs. - Remove obsolete queries and DB functions. - Document the `core` package.
30 lines
910 B
Go
30 lines
910 B
Go
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) {
|
|
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) {
|
|
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
|
|
}
|