-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1380 from open-zaak/issue/1363-speedup-eio
⚡ [#1363] Optimize EIO endpoint performance
- Loading branch information
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SPDX-License-Identifier: EUPL-1.2 | ||
# Copyright (C) 2023 Dimpact | ||
from django.conf import settings | ||
from django.core.paginator import Paginator as DjangoPaginator | ||
from django.utils.functional import cached_property | ||
|
||
from rest_framework.pagination import PageNumberPagination | ||
|
||
|
||
class EnkelvoudigInformatieObjectPaginator(DjangoPaginator): | ||
@cached_property | ||
def count(self): | ||
""" | ||
⚡ restricts values to PK to remove implicit join from SQL query | ||
""" | ||
if not settings.CMIS_ENABLED: | ||
# Objects in CMISQuerySet do not have `pk`s | ||
return self.object_list.values("pk").count() | ||
return super().count | ||
|
||
|
||
class EnkelvoudigInformatieObjectPagination(PageNumberPagination): | ||
django_paginator_class = EnkelvoudigInformatieObjectPaginator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters