mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	only show inbox statistics if inbox tags are defined
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| <app-widget-frame title="Statistics" i18n-title> | <app-widget-frame title="Statistics" i18n-title> | ||||||
|   <ng-container content> |   <ng-container content> | ||||||
|     <p class="card-text" i18n>Documents in inbox: {{statistics.documents_inbox}}</p> |     <p class="card-text" i18n *ngIf="statistics?.documents_inbox != null">Documents in inbox: {{statistics?.documents_inbox}}</p> | ||||||
|     <p class="card-text" i18n>Total documents: {{statistics.documents_total}}</p> |     <p class="card-text" i18n>Total documents: {{statistics?.documents_total}}</p> | ||||||
|   </ng-container> |   </ng-container> | ||||||
| </app-widget-frame> | </app-widget-frame> | ||||||
|   | |||||||
| @@ -442,6 +442,13 @@ class TestDocumentApi(DirectoriesMixin, APITestCase): | |||||||
|         self.assertEqual(response.data['documents_total'], 3) |         self.assertEqual(response.data['documents_total'], 3) | ||||||
|         self.assertEqual(response.data['documents_inbox'], 1) |         self.assertEqual(response.data['documents_inbox'], 1) | ||||||
|  |  | ||||||
|  |     def test_statistics_no_inbox_tag(self): | ||||||
|  |         Document.objects.create(title="none1", checksum="A") | ||||||
|  |  | ||||||
|  |         response = self.client.get("/api/statistics/") | ||||||
|  |         self.assertEqual(response.status_code, 200) | ||||||
|  |         self.assertEqual(response.data['documents_inbox'], None) | ||||||
|  |  | ||||||
|     @mock.patch("documents.views.async_task") |     @mock.patch("documents.views.async_task") | ||||||
|     def test_upload(self, m): |     def test_upload(self, m): | ||||||
|  |  | ||||||
|   | |||||||
| @@ -595,8 +595,14 @@ class StatisticsView(APIView): | |||||||
|     permission_classes = (IsAuthenticated,) |     permission_classes = (IsAuthenticated,) | ||||||
|  |  | ||||||
|     def get(self, request, format=None): |     def get(self, request, format=None): | ||||||
|         return Response({ |         documents_total = Document.objects.all().count() | ||||||
|             'documents_total': Document.objects.all().count(), |         if Tag.objects.filter(is_inbox_tag=True).exists(): | ||||||
|             'documents_inbox': Document.objects.filter( |             documents_inbox = Document.objects.filter( | ||||||
|                 tags__is_inbox_tag=True).distinct().count() |                 tags__is_inbox_tag=True).distinct().count() | ||||||
|  |         else: | ||||||
|  |             documents_inbox = None | ||||||
|  |  | ||||||
|  |         return Response({ | ||||||
|  |             'documents_total': documents_total, | ||||||
|  |             'documents_inbox': documents_inbox, | ||||||
|         }) |         }) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jonaswinkler
					jonaswinkler