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 # Module imports
from .base import BaseSerializer from .base import BaseSerializer
from .user import UserLiteSerializer from .user import UserLiteSerializer
from .project import ProjectLiteSerializer
from plane.db.models import Importer from plane.db.models import Importer
class ImporterSerializer(BaseSerializer): class ImporterSerializer(BaseSerializer):
initiated_by_detail = UserLiteSerializer(source="initiated_by", read_only=True) initiated_by_detail = UserLiteSerializer(source="initiated_by", read_only=True)
project_detail = ProjectLiteSerializer(source="project", read_only=True)
class Meta: class Meta:
model = Importer model = Importer

View File

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