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.core import serializers
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.gzip import gzip_page
# Third party imports
from rest_framework.response import Response
@ -169,6 +171,7 @@ class CycleIssueViewSet(BaseViewSet):
.distinct()
)
@method_decorator(gzip_page)
def list(self, request, slug, project_id, cycle_id):
try:
order_by = request.GET.get("order_by", "created_at")

View File

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

View File

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

View File

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