Enhance dashboard summary and statistics with new fields and caching improvements
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Added new field `Days` and `ScrapedTED` to `SummaryResponse` for tracking daily TED scrape counts. - Updated `SummaryQuery` to include `Days` parameter for querying scraped TED data. - Modified `Summary` handler to accept and process the new `Days` parameter. - Refactored `Summary` method in the repository to support the new `Days` parameter and improved aggregation logic. - Enhanced caching logic in the service layer to utilize a composite cache key based on `closingWindowSec` and `days`, improving cache management and retrieval efficiency. This update improves the dashboard's functionality by providing more detailed insights into TED scraping activities and optimizing the caching strategy for better performance.
This commit is contained in:
@@ -19,10 +19,11 @@ func NewHandler(service Service) *Handler {
|
||||
|
||||
// Summary returns top-level dashboard counters.
|
||||
// @Summary Dashboard summary
|
||||
// @Description Top-level counters for hero pills and stat cards
|
||||
// @Description Top-level counters for hero pills and stat cards, including daily TED scrape counts
|
||||
// @Tags Admin-Dashboard
|
||||
// @Produce json
|
||||
// @Param closing_window query int false "Hours considered closing soon (default 168)"
|
||||
// @Param days query int false "Days back for scraped TED daily series (default 14, max 90)"
|
||||
// @Success 200 {object} response.APIResponse{data=SummaryResponse}
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /admin/v1/dashboard/summary [get]
|
||||
@@ -30,6 +31,7 @@ func NewHandler(service Service) *Handler {
|
||||
func (h *Handler) Summary(c echo.Context) error {
|
||||
query := SummaryQuery{
|
||||
ClosingWindow: parseIntQuery(c, "closing_window", 0),
|
||||
Days: parseIntQuery(c, "days", 0),
|
||||
}
|
||||
|
||||
out, err := h.service.Summary(c.Request().Context(), query)
|
||||
@@ -37,7 +39,7 @@ func (h *Handler) Summary(c echo.Context) error {
|
||||
return response.InternalServerError(c, "Failed to load dashboard summary")
|
||||
}
|
||||
|
||||
setPrivateCache(c, 60)
|
||||
setPrivateCache(c, 300)
|
||||
return response.Success(c, out, "Dashboard summary retrieved successfully")
|
||||
}
|
||||
|
||||
@@ -163,7 +165,7 @@ func (h *Handler) Recent(c echo.Context) error {
|
||||
|
||||
// Statistics returns scraping and translation statistics for charts.
|
||||
// @Summary Dashboard statistics report
|
||||
// @Description Daily and lifetime statistics for TED scraping, document scraping, and AI translation
|
||||
// @Description Daily and lifetime statistics for document scraping and AI translation
|
||||
// @Tags Admin-Dashboard
|
||||
// @Produce json
|
||||
// @Param days query int false "Days back for daily series (default 14, max 90)"
|
||||
|
||||
Reference in New Issue
Block a user