Skip to content

Commit 3c87ec5

Browse files
committed
feat: add API endpoints for retrieving shared tool records and individual tool record details
1 parent 258f6ca commit 3c87ec5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

apps/tools/serializers/tool.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,14 @@ def get_tool_records(self, current_page: int, page_size: int):
919919
default=Value(''),
920920
output_field=CharField()
921921
)
922+
).annotate(
923+
tool_name=Subquery(
924+
Tool.objects.filter(id=OuterRef('tool_id')).values('name')[:1]
925+
)
926+
).annotate(
927+
tool_icon=Subquery(
928+
Tool.objects.filter(id=OuterRef('tool_id')).values('icon')[:1]
929+
)
922930
)
923931
if self.data.get('source_type'):
924932
query_set = query_set.filter(Q(source_type=self.data.get('source_type', '')))
@@ -937,6 +945,8 @@ def get_tool_records(self, current_page: int, page_size: int):
937945
lambda record: {
938946
**ToolRecordModelSerializer(record).data,
939947
'source_name': record.source_name,
948+
'tool_name': record.tool_name,
949+
'tool_icon': record.tool_icon,
940950
}
941951
)
942952

0 commit comments

Comments
 (0)