Skip to content

Commit

Permalink
Round displayed stakeholder criticality
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Dec 16, 2024
1 parent f1b00d8 commit b47f41d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions backend/ebios_rm/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ class Meta:


class StakeholderWriteSerializer(BaseModelSerializer):
current_criticality = serializers.IntegerField(read_only=True)
residual_criticality = serializers.IntegerField(read_only=True)
current_criticality = serializers.DecimalField(
max_digits=5, decimal_places=2, read_only=True
)
residual_criticality = serializers.DecimalField(
max_digits=5, decimal_places=2, read_only=True
)

class Meta:
model = Stakeholder
Expand All @@ -120,8 +124,8 @@ class StakeholderReadSerializer(BaseModelSerializer):
applied_controls = FieldsRelatedField(many=True)

category = serializers.CharField(source="get_category_display")
current_criticality = serializers.IntegerField()
residual_criticality = serializers.IntegerField()
current_criticality = serializers.DecimalField(max_digits=5, decimal_places=2)
residual_criticality = serializers.DecimalField(max_digits=5, decimal_places=2)

class Meta:
model = Stakeholder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
trust: number
) => {
if (maturity === 0 || trust === 0) return 0;
return (dependency * penetration) / (maturity * trust);
return ((dependency * penetration) / (maturity * trust)).toFixed(2).replace(/\.0+$/, '');
};
$: currentCriticality = getCriticality(
Expand Down

0 comments on commit b47f41d

Please sign in to comment.