Files
tm_back/internal/dashboard/entity.go
T
Mazyar 541d08a014
continuous-integration/drone/push Build is passing
Enhance dashboard summary and statistics with new fields and caching improvements
- 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.
2026-07-01 23:03:23 +03:30

111 lines
3.7 KiB
Go

package dashboard
// SummaryResponse powers hero pills and stat cards.
type SummaryResponse struct {
TotalTenders int64 `json:"total_tenders"`
ActiveTenders int64 `json:"active_tenders"`
AwardedTenders int64 `json:"awarded_tenders"`
ExpiredTenders int64 `json:"expired_tenders"`
CancelledTenders int64 `json:"cancelled_tenders"`
ClosingSoon int64 `json:"closing_soon"`
TotalEstimatedValue float64 `json:"total_estimated_value"`
ValueCurrency string `json:"value_currency"`
Days int `json:"days"`
ScrapedTED []TrendPoint `json:"scraped_ted"`
GeneratedAt int64 `json:"generated_at"`
}
// TrendResponse powers the tender flow chart.
type TrendResponse struct {
Metric string `json:"metric"`
Days int `json:"days"`
Series []TrendPoint `json:"series"`
}
// TrendPoint is a single day in the trend series.
type TrendPoint struct {
Date string `json:"date"`
Count int64 `json:"count"`
}
// CountriesResponse powers the country distribution widget.
type CountriesResponse struct {
Total int64 `json:"total"`
Items []CountryItem `json:"items"`
OtherCount int64 `json:"other_count"`
}
// CountryItem is a country bucket in the distribution.
type CountryItem struct {
CountryCode string `json:"country_code"`
Count int64 `json:"count"`
}
// NoticeTypesResponse powers the notice type mix widget.
type NoticeTypesResponse struct {
Total int64 `json:"total"`
Items []NoticeTypeItem `json:"items"`
}
// NoticeTypeItem is a notice type bucket.
type NoticeTypeItem struct {
Type string `json:"type"`
Count int64 `json:"count"`
}
// ClosingSoonResponse powers the closing soon card.
type ClosingSoonResponse struct {
Items []ClosingSoonItem `json:"items"`
}
// ClosingSoonItem is a tender closing within the configured window.
type ClosingSoonItem struct {
ID string `json:"id"`
Title string `json:"title"`
CountryCode string `json:"country_code"`
BuyerName string `json:"buyer_name"`
SubmissionDeadline int64 `json:"submission_deadline"`
TenderDeadline int64 `json:"tender_deadline"`
Status string `json:"status"`
EstimatedValue float64 `json:"estimated_value"`
Currency string `json:"currency"`
}
// RecentResponse powers the recent tenders feed.
type RecentResponse struct {
Items []RecentItem `json:"items"`
NextCursor *string `json:"next_cursor"`
}
// RecentItem is a row in the recent tenders list.
type RecentItem struct {
ID string `json:"id"`
Title string `json:"title"`
CountryCode string `json:"country_code"`
Status string `json:"status"`
BuyerName string `json:"buyer_name"`
CreatedAt int64 `json:"created_at"`
PublicationDate int64 `json:"publication_date"`
}
// StatisticsReportResponse powers the statistics and charts report.
type StatisticsReportResponse struct {
Days int `json:"days"`
GeneratedAt int64 `json:"generated_at"`
Daily StatisticsDailySeries `json:"daily"`
Totals StatisticsLifetimeTotals `json:"totals"`
}
// StatisticsDailySeries contains per-day chart series.
type StatisticsDailySeries struct {
ScrapedDocuments []TrendPoint `json:"scraped_documents"`
TranslatedNotices []TrendPoint `json:"translated_notices"`
}
// StatisticsLifetimeTotals contains all-time totals.
type StatisticsLifetimeTotals struct {
ScrapedDocuments int64 `json:"scraped_documents"`
TranslatedTenders int64 `json:"translated_tenders"`
ScrapedTEDNotices int64 `json:"scraped_ted_notices"`
}