mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Enhancement: display current ASN in statistics (#6692)
This commit is contained in:
		| @@ -2471,7 +2471,7 @@ | |||||||
|         </context-group> |         </context-group> | ||||||
|         <context-group purpose="location"> |         <context-group purpose="location"> | ||||||
|           <context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html</context> |           <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> |         </context-group> | ||||||
|       </trans-unit> |       </trans-unit> | ||||||
|       <trans-unit id="7886570921510760899" datatype="html"> |       <trans-unit id="7886570921510760899" datatype="html"> | ||||||
| @@ -2490,7 +2490,7 @@ | |||||||
|         </context-group> |         </context-group> | ||||||
|         <context-group purpose="location"> |         <context-group purpose="location"> | ||||||
|           <context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html</context> |           <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> | ||||||
|         <context-group purpose="location"> |         <context-group purpose="location"> | ||||||
|           <context context-type="sourcefile">src/app/components/document-list/bulk-editor/bulk-editor.component.html</context> |           <context context-type="sourcefile">src/app/components/document-list/bulk-editor/bulk-editor.component.html</context> | ||||||
| @@ -2521,7 +2521,7 @@ | |||||||
|         </context-group> |         </context-group> | ||||||
|         <context-group purpose="location"> |         <context-group purpose="location"> | ||||||
|           <context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html</context> |           <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> |         </context-group> | ||||||
|       </trans-unit> |       </trans-unit> | ||||||
|       <trans-unit id="5421255270838137624" datatype="html"> |       <trans-unit id="5421255270838137624" datatype="html"> | ||||||
| @@ -2536,7 +2536,7 @@ | |||||||
|         </context-group> |         </context-group> | ||||||
|         <context-group purpose="location"> |         <context-group purpose="location"> | ||||||
|           <context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html</context> |           <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> |         </context-group> | ||||||
|       </trans-unit> |       </trans-unit> | ||||||
|       <trans-unit id="3188389494264426470" datatype="html"> |       <trans-unit id="3188389494264426470" datatype="html"> | ||||||
| @@ -5196,11 +5196,18 @@ | |||||||
|           <context context-type="linenumber">15</context> |           <context context-type="linenumber">15</context> | ||||||
|         </context-group> |         </context-group> | ||||||
|       </trans-unit> |       </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"> |       <trans-unit id="8693603235657020323" datatype="html"> | ||||||
|         <source>Other</source> |         <source>Other</source> | ||||||
|         <context-group purpose="location"> |         <context-group purpose="location"> | ||||||
|           <context context-type="sourcefile">src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts</context> |           <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> |         </context-group> | ||||||
|       </trans-unit> |       </trans-unit> | ||||||
|       <trans-unit id="8187573012244728580" datatype="html"> |       <trans-unit id="8187573012244728580" datatype="html"> | ||||||
|   | |||||||
| @@ -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, | ||||||
|             }, |             }, | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Daniel
					Daniel