Skip to content

Commit 9a344be

Browse files
committed
fix: add calculateWeightedEffort method to DtoUtils and refactor EffortRatingDTO to use it
1 parent 4cb6a1c commit 9a344be

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/main/java/de/tum/cit/aet/ai/dto/EffortRatingDTO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.tum.cit.aet.ai.dto;
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import de.tum.cit.aet.analysis.util.DtoUtils;
45

56
/**
67
* Result of LLM-based effort rating for a commit chunk.
@@ -32,8 +33,7 @@ public record EffortRatingDTO(
3233
* Normalizes to roughly match raw effort score but considers quality.
3334
*/
3435
public double weightedEffort() {
35-
double qualityMultiplier = 0.5 + (0.3 * complexity / 10.0) + (0.2 * novelty / 10.0);
36-
return effortScore * qualityMultiplier;
36+
return DtoUtils.calculateWeightedEffort(effortScore, complexity, novelty);
3737
}
3838

3939
/**

src/main/java/de/tum/cit/aet/analysis/util/DtoUtils.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,19 @@ private DtoUtils() {
1919
public static int calculateLinesChanged(int linesAdded, int linesDeleted) {
2020
return linesAdded + linesDeleted;
2121
}
22+
23+
/**
24+
* Calculates a weighted effort score.
25+
* Formula: effortScore * (0.5 + 0.3*complexity + 0.2*novelty) / 10
26+
* Normalizes to roughly match raw effort score but considers quality.
27+
*
28+
* @param effortScore raw effort score (1-10)
29+
* @param complexity technical complexity (1-10)
30+
* @param novelty originality of the work (1-10)
31+
* @return weighted effort score
32+
*/
33+
public static double calculateWeightedEffort(double effortScore, double complexity, double novelty) {
34+
double qualityMultiplier = 0.5 + (0.3 * complexity / 10.0) + (0.2 * novelty / 10.0);
35+
return effortScore * qualityMultiplier;
36+
}
2237
}

0 commit comments

Comments
 (0)