diff --git a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html index 49ebc5ae5..18f28ddfc 100644 --- a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html +++ b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html @@ -15,6 +15,12 @@ Total characters: {{statistics?.character_count | number}} + @if (statistics?.current_asn) { +
+ Current ASN: + {{statistics?.current_asn | number}} +
+ } @if (statistics?.document_file_type_counts?.length > 1) {
diff --git a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.spec.ts b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.spec.ts index 43ab4d248..7d14af6ad 100644 --- a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.spec.ts +++ b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.spec.ts @@ -189,4 +189,38 @@ describe('StatisticsWidgetComponent', () => { 'Other(0.9%)' ) }) + + it('should display the current ASN', () => { + const mockStats = { + current_asn: 122, + } + + const req = httpTestingController.expectOne( + `${environment.apiBaseUrl}statistics/` + ) + + req.flush(mockStats) + fixture.detectChanges() + + expect(fixture.nativeElement.textContent.replace(/\s/g, '')).toContain( + 'CurrentASN:122' + ) + }) + + it('should not display the current ASN if it is not available', () => { + const mockStats = { + current_asn: 0, + } + + const req = httpTestingController.expectOne( + `${environment.apiBaseUrl}statistics/` + ) + + req.flush(mockStats) + fixture.detectChanges() + + expect(fixture.nativeElement.textContent.replace(/\s/g, '')).not.toContain( + 'CurrentASN:' + ) + }) }) diff --git a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts index 01799e9ac..e52a9b69c 100644 --- a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts +++ b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts @@ -18,6 +18,7 @@ export interface Statistics { correspondent_count?: number document_type_count?: number storage_path_count?: number + current_asn?: number } interface DocumentFileType { diff --git a/src/documents/views.py b/src/documents/views.py index 6005b1938..89a4a9011 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -1414,6 +1414,12 @@ class StatisticsView(APIView): .get("characters__sum") ) + current_asn = Document.objects.aggregate( + Max("archive_serial_number", default=0), + ).get( + "archive_serial_number__max", + ) + return Response( { "documents_total": documents_total, @@ -1425,6 +1431,7 @@ class StatisticsView(APIView): "correspondent_count": correspondent_count, "document_type_count": document_type_count, "storage_path_count": storage_path_count, + "current_asn": current_asn, }, )