mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Performance improvement for notifications API endpoint (#7154)
* Prefecth notifications queryset * Apply prefetch to detail endpoint also * Improve prefetch fields
This commit is contained in:
		| @@ -357,6 +357,22 @@ class NotificationMessageMixin: | ||||
|     serializer_class = common.serializers.NotificationMessageSerializer | ||||
|     permission_classes = [UserSettingsPermissions] | ||||
|  | ||||
|     def get_queryset(self): | ||||
|         """Return prefetched queryset.""" | ||||
|         queryset = ( | ||||
|             super() | ||||
|             .get_queryset() | ||||
|             .prefetch_related( | ||||
|                 'source_content_type', | ||||
|                 'source_object', | ||||
|                 'target_content_type', | ||||
|                 'target_object', | ||||
|                 'user', | ||||
|             ) | ||||
|         ) | ||||
|  | ||||
|         return queryset | ||||
|  | ||||
|  | ||||
| class NotificationList(NotificationMessageMixin, BulkDeleteMixin, ListAPI): | ||||
|     """List view for all notifications of the current user.""" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user