Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Enhancement: display current ASN in statistics (#6692)

Daniel52350f8b5192
diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf
index 3432faa57..4be198d69 100644
--- a/src-ui/messages.xlf
+++ b/src-ui/messages.xlf
@@ -2471,7 +2471,7 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html</context>
- <context context-type="linenumber">66</context>
+ <context context-type="linenumber">72</context>
</context-group>
</trans-unit>
<trans-unit id="7886570921510760899" datatype="html">
@@ -2490,7 +2490,7 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html</context>
- <context context-type="linenumber">58</context>
+ <context context-type="linenumber">64</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/document-list/bulk-editor/bulk-editor.component.html</context>
@@ -2521,7 +2521,7 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html</context>
- <context context-type="linenumber">74</context>
+ <context context-type="linenumber">80</context>
</context-group>
</trans-unit>
<trans-unit id="5421255270838137624" datatype="html">
@@ -2536,7 +2536,7 @@
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html</context>
- <context context-type="linenumber">82</context>
+ <context context-type="linenumber">88</context>
</context-group>
</trans-unit>
<trans-unit id="3188389494264426470" datatype="html">
@@ -5196,11 +5196,18 @@
<context context-type="linenumber">15</context>
</context-group>
</trans-unit>
+ <trans-unit id="3047655754312785383" datatype="html">
+ <source>Current ASN</source>
+ <context-group purpose="location">
+ <context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html</context>
+ <context context-type="linenumber">20</context>
+ </context-group>
+ </trans-unit>
<trans-unit id="8693603235657020323" datatype="html">
<source>Other</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts</context>
- <context context-type="linenumber">65</context>
+ <context context-type="linenumber">66</context>
</context-group>
</trans-unit>
<trans-unit id="8187573012244728580" datatype="html">
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 @@
<ng-container i18n>Total characters</ng-container>:
<span class="badge bg-secondary text-light rounded-pill">{{statistics?.character_count | number}}</span>
</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) {
<div class="list-group-item filetypes">
<div class="d-flex justify-content-between align-items-center my-2">
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,
},
)