Add translated notices scanning functionality to dashboard repository
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Introduced a new `translatedNoticesScanner` interface for scanning MinIO for daily translated notice counts. - Enhanced the `repository` struct to include fields for managing translated notice scope and caching. - Implemented the `ScanTranslatedNotices` method in the `StorageClient` to retrieve daily counts and total from MinIO. - Updated the `Statistics` method in the repository to utilize the new translated notices scope, improving data accuracy. - Added unit tests for the translated notices functionality, ensuring robust validation of the new features. This update significantly enhances the dashboard's ability to handle translated notice statistics, improving overall data management and reporting capabilities.
This commit is contained in:
@@ -29,6 +29,10 @@ type mockProcedureDocumentsLister struct {
|
||||
procedures []ai_summarizer.ProcedureDocumentsSummary
|
||||
dailyCounts map[string]int64
|
||||
err error
|
||||
|
||||
translatedDailyCounts map[string]int64
|
||||
translatedTotal int64
|
||||
translatedErr error
|
||||
}
|
||||
|
||||
func (m *mockProcedureDocumentsLister) ListProceduresWithDocuments(context.Context) ([]ai_summarizer.ProcedureDocumentsSummary, error) {
|
||||
@@ -45,6 +49,13 @@ func (m *mockProcedureDocumentsLister) ScanScrapedDocuments(context.Context) ([]
|
||||
return m.procedures, m.dailyCounts, nil
|
||||
}
|
||||
|
||||
func (m *mockProcedureDocumentsLister) ScanTranslatedNotices(context.Context) (map[string]int64, int64, error) {
|
||||
if m.translatedErr != nil {
|
||||
return nil, 0, m.translatedErr
|
||||
}
|
||||
return m.translatedDailyCounts, m.translatedTotal, nil
|
||||
}
|
||||
|
||||
func TestScrapedDocumentsFolderIDsUsesMinIOProcedures(t *testing.T) {
|
||||
repo := &repository{
|
||||
procedureLister: &mockProcedureDocumentsLister{
|
||||
@@ -259,3 +270,41 @@ func TestMongoScrapedTendersScopeMatchesStatisticsFilter(t *testing.T) {
|
||||
t.Fatalf("expected documents_scraped filter, got %#v", scope.match)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveTranslatedNoticesScopeUsesMinIOCounts(t *testing.T) {
|
||||
repo := &repository{
|
||||
procedureLister: &mockProcedureDocumentsLister{
|
||||
translatedDailyCounts: map[string]int64{
|
||||
"2026-07-01": 4,
|
||||
"2026-07-09": 2,
|
||||
},
|
||||
translatedTotal: 6,
|
||||
},
|
||||
}
|
||||
|
||||
scope, err := repo.resolveTranslatedNoticesScope(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if !scope.fromMinIO {
|
||||
t.Fatal("expected MinIO-backed translation scope")
|
||||
}
|
||||
if scope.totalCount != 6 {
|
||||
t.Fatalf("expected total 6, got %d", scope.totalCount)
|
||||
}
|
||||
if scope.dailyCounts["2026-07-09"] != 2 {
|
||||
t.Fatalf("expected 2 on 2026-07-09, got %d", scope.dailyCounts["2026-07-09"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveTranslatedNoticesScopeWithoutLister(t *testing.T) {
|
||||
repo := &repository{}
|
||||
|
||||
scope, err := repo.resolveTranslatedNoticesScope(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if scope.fromMinIO {
|
||||
t.Fatal("expected metrics fallback without lister")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user