chore: add project details on importer service endpoint (#714)

* chore: add project details on importer service endpoint

* dev: add select related for imports
This commit is contained in:
pablohashescobar 2023-04-06 22:57:06 +05:30 committed by GitHub
parent 5b72b1672f
commit e46487c130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -1,11 +1,13 @@
# Module imports
from .base import BaseSerializer
from .user import UserLiteSerializer
from .project import ProjectLiteSerializer
from plane.db.models import Importer
class ImporterSerializer(BaseSerializer):
initiated_by_detail = UserLiteSerializer(source="initiated_by", read_only=True)
project_detail = ProjectLiteSerializer(source="project", read_only=True)
class Meta:
model = Importer

View File

@ -213,8 +213,10 @@ class ImportServiceEndpoint(BaseAPIView):
def get(self, request, slug):
try:
imports = Importer.objects.filter(workspace__slug=slug).order_by(
"-created_at"
imports = (
Importer.objects.filter(workspace__slug=slug)
.order_by("-created_at")
.select_related("initiated_by", "project", "workspace")
)
serializer = ImporterSerializer(imports, many=True)
return Response(serializer.data)