feat: gzip compressor for performance upgrades (#538)

This commit is contained in:
pablohashescobar 2023-03-27 23:36:13 +05:30 committed by GitHub
parent 35b80b422d
commit 8bd557a743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

View File

@ -6,6 +6,8 @@ from django.db import IntegrityError
from django.db.models import OuterRef, Func, F, Q, Exists, OuterRef, Count, Prefetch from django.db.models import OuterRef, Func, F, Q, Exists, OuterRef, Count, Prefetch
from django.core import serializers from django.core import serializers
from django.utils import timezone from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.gzip import gzip_page
# Third party imports # Third party imports
from rest_framework.response import Response from rest_framework.response import Response
@ -169,6 +171,7 @@ class CycleIssueViewSet(BaseViewSet):
.distinct() .distinct()
) )
@method_decorator(gzip_page)
def list(self, request, slug, project_id, cycle_id): def list(self, request, slug, project_id, cycle_id):
try: try:
order_by = request.GET.get("order_by", "created_at") order_by = request.GET.get("order_by", "created_at")

View File

@ -6,7 +6,8 @@ from itertools import groupby, chain
# Django imports # Django imports
from django.db.models import Prefetch, OuterRef, Func, F, Q from django.db.models import Prefetch, OuterRef, Func, F, Q
from django.core.serializers.json import DjangoJSONEncoder from django.core.serializers.json import DjangoJSONEncoder
from django.utils.decorators import method_decorator
from django.views.decorators.gzip import gzip_page
# Third Party imports # Third Party imports
from rest_framework.response import Response from rest_framework.response import Response
@ -139,6 +140,7 @@ class IssueViewSet(BaseViewSet):
.prefetch_related("labels") .prefetch_related("labels")
) )
@method_decorator(gzip_page)
def list(self, request, slug, project_id): def list(self, request, slug, project_id):
try: try:
filters = issue_filters(request.query_params, "GET") filters = issue_filters(request.query_params, "GET")
@ -218,6 +220,7 @@ class IssueViewSet(BaseViewSet):
class UserWorkSpaceIssues(BaseAPIView): class UserWorkSpaceIssues(BaseAPIView):
@method_decorator(gzip_page)
def get(self, request, slug): def get(self, request, slug):
try: try:
issues = ( issues = (
@ -251,6 +254,7 @@ class WorkSpaceIssuesEndpoint(BaseAPIView):
WorkSpaceAdminPermission, WorkSpaceAdminPermission,
] ]
@method_decorator(gzip_page)
def get(self, request, slug): def get(self, request, slug):
try: try:
issues = ( issues = (
@ -273,6 +277,7 @@ class IssueActivityEndpoint(BaseAPIView):
ProjectEntityPermission, ProjectEntityPermission,
] ]
@method_decorator(gzip_page)
def get(self, request, slug, project_id, issue_id): def get(self, request, slug, project_id, issue_id):
try: try:
issue_activities = ( issue_activities = (
@ -554,6 +559,7 @@ class SubIssuesEndpoint(BaseAPIView):
ProjectEntityPermission, ProjectEntityPermission,
] ]
@method_decorator(gzip_page)
def get(self, request, slug, project_id, issue_id): def get(self, request, slug, project_id, issue_id):
try: try:
sub_issues = ( sub_issues = (

View File

@ -5,6 +5,8 @@ import json
from django.db import IntegrityError from django.db import IntegrityError
from django.db.models import Prefetch, F, OuterRef, Func, Exists, Count, Q from django.db.models import Prefetch, F, OuterRef, Func, Exists, Count, Q
from django.core import serializers from django.core import serializers
from django.utils.decorators import method_decorator
from django.views.decorators.gzip import gzip_page
# Third party imports # Third party imports
from rest_framework.response import Response from rest_framework.response import Response
@ -177,6 +179,7 @@ class ModuleIssueViewSet(BaseViewSet):
.distinct() .distinct()
) )
@method_decorator(gzip_page)
def list(self, request, slug, project_id, module_id): def list(self, request, slug, project_id, module_id):
try: try:
order_by = request.GET.get("order_by", "created_at") order_by = request.GET.get("order_by", "created_at")

View File

@ -48,6 +48,7 @@ MIDDLEWARE = [
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
"crum.CurrentRequestUserMiddleware", "crum.CurrentRequestUserMiddleware",
"django.middleware.gzip.GZipMiddleware",
] ]
REST_FRAMEWORK = { REST_FRAMEWORK = {