mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +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:
parent
76b298c43e
commit
bb93c915ee
@ -357,6 +357,22 @@ class NotificationMessageMixin:
|
|||||||
serializer_class = common.serializers.NotificationMessageSerializer
|
serializer_class = common.serializers.NotificationMessageSerializer
|
||||||
permission_classes = [UserSettingsPermissions]
|
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):
|
class NotificationList(NotificationMessageMixin, BulkDeleteMixin, ListAPI):
|
||||||
"""List view for all notifications of the current user."""
|
"""List view for all notifications of the current user."""
|
||||||
|
Loading…
Reference in New Issue
Block a user