68b170126d
- Updated `InitAISummarizerClient` to accept `mongoManager` for tracking translation success. - Introduced new `Statistics` endpoint in the dashboard to fetch scraping and translation statistics. - Enhanced `TranslationWorker` to utilize the new success counter for tracking successful translations. - Added necessary data structures and query forms for statistics reporting. This refactor improves the tracking of AI translation success and provides new insights through the dashboard statistics.
109 lines
3.5 KiB
Go
109 lines
3.5 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"`
|
|
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 {
|
|
ScrapedTED []TrendPoint `json:"scraped_ted"`
|
|
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"`
|
|
}
|