feat[dashboard]: show current ASN in dashboard statistics
This commit is contained in:
parent
6fa3522618
commit
0e4673b1e2
@ -15,6 +15,12 @@
|
|||||||
<ng-container i18n>Total characters</ng-container>:
|
<ng-container i18n>Total characters</ng-container>:
|
||||||
<span class="badge bg-secondary text-light rounded-pill">{{statistics?.character_count | number}}</span>
|
<span class="badge bg-secondary text-light rounded-pill">{{statistics?.character_count | number}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@if (statistics?.current_asn) {
|
||||||
|
<div class="list-group-item d-flex justify-content-between align-items-center" routerLink="/documents/">
|
||||||
|
<ng-container i18n>Current ASN</ng-container>:
|
||||||
|
<span class="badge bg-secondary text-light rounded-pill">{{statistics?.current_asn | number}}</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
@if (statistics?.document_file_type_counts?.length > 1) {
|
@if (statistics?.document_file_type_counts?.length > 1) {
|
||||||
<div class="list-group-item filetypes">
|
<div class="list-group-item filetypes">
|
||||||
<div class="d-flex justify-content-between align-items-center my-2">
|
<div class="d-flex justify-content-between align-items-center my-2">
|
||||||
|
@ -189,4 +189,38 @@ describe('StatisticsWidgetComponent', () => {
|
|||||||
'Other(0.9%)'
|
'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:'
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -18,6 +18,7 @@ export interface Statistics {
|
|||||||
correspondent_count?: number
|
correspondent_count?: number
|
||||||
document_type_count?: number
|
document_type_count?: number
|
||||||
storage_path_count?: number
|
storage_path_count?: number
|
||||||
|
current_asn?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DocumentFileType {
|
interface DocumentFileType {
|
||||||
|
@ -1414,6 +1414,12 @@ class StatisticsView(APIView):
|
|||||||
.get("characters__sum")
|
.get("characters__sum")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
current_asn = Document.objects.aggregate(
|
||||||
|
Max("archive_serial_number", default=0),
|
||||||
|
).get(
|
||||||
|
"archive_serial_number__max",
|
||||||
|
)
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
"documents_total": documents_total,
|
"documents_total": documents_total,
|
||||||
@ -1425,6 +1431,7 @@ class StatisticsView(APIView):
|
|||||||
"correspondent_count": correspondent_count,
|
"correspondent_count": correspondent_count,
|
||||||
"document_type_count": document_type_count,
|
"document_type_count": document_type_count,
|
||||||
"storage_path_count": storage_path_count,
|
"storage_path_count": storage_path_count,
|
||||||
|
"current_asn": current_asn,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user