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

Commit 81643ce

Browse files
committed
fix attribute rename
1 parent 55a2757 commit 81643ce

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

api/shared/report/serializers.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from rest_framework import serializers
44

5-
from services.path import Dir
5+
from services.path import Dir, File
66

77

88
class TreeSerializer(serializers.Serializer):
@@ -14,7 +14,7 @@ class TreeSerializer(serializers.Serializer):
1414
partials = serializers.IntegerField()
1515
misses = serializers.IntegerField()
1616

17-
def to_representation(self, instance: Dir) -> dict:
17+
def to_representation(self, instance: Dir | File) -> dict:
1818
depth = self.context.get("depth", 1)
1919
max_depth = self.context.get("max_depth", math.inf)
2020
res = super().to_representation(instance)
@@ -36,11 +36,15 @@ class SunburstSerializer(serializers.Serializer):
3636
full_path = serializers.CharField()
3737
value = serializers.FloatField()
3838

39-
def to_representation(self, instance: Dir) -> dict:
39+
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-
if isinstance(instance, Dir):
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):
4448
if depth < max_depth:
4549
res["children"] = SunburstSerializer(
4650
instance.children,

0 commit comments

Comments
 (0)