Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 1c84a29

Browse files
committed
try to use source option
1 parent 81643ce commit 1c84a29

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

api/shared/report/serializers.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,13 @@ def to_representation(self, instance: Dir | File) -> dict:
3434
class SunburstSerializer(serializers.Serializer):
3535
name = serializers.CharField()
3636
full_path = serializers.CharField()
37-
value = serializers.FloatField()
37+
value = serializers.FloatField(source="coverage")
3838

3939
def to_representation(self, instance: Dir | File) -> dict:
4040
depth = self.context.get("depth", 1)
4141
max_depth = self.context.get("max_depth", math.inf)
4242
res = super().to_representation(instance)
43-
44-
# Adjust the "value" field based on the instance type
45-
if isinstance(instance, File):
46-
res["value"] = instance.coverage
47-
elif isinstance(instance, Dir):
43+
if isinstance(instance, Dir):
4844
if depth < max_depth:
4945
res["children"] = SunburstSerializer(
5046
instance.children,

0 commit comments

Comments
 (0)