Skip to content

Commit 3d7e3be

Browse files
committed
Removed TrendSummaryDto and related methods from AnalysisController and AnalysisService
1 parent 84f4c95 commit 3d7e3be

File tree

2 files changed

+0
-34
lines changed

2 files changed

+0
-34
lines changed

src/main/java/com/openelements/conduct/controller/AnalysisController.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.openelements.conduct.controller;
22

33
import com.openelements.conduct.api.dto.AnalysisDto;
4-
import com.openelements.conduct.api.dto.TrendSummaryDto;
54
import com.openelements.conduct.service.AnalysisService;
65
import org.jspecify.annotations.NonNull;
76
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,9 +25,4 @@ public AnalysisController(@NonNull AnalysisService analysisService) {
2625
public AnalysisDto getAnalysis() {
2726
return analysisService.generateAnalysis();
2827
}
29-
30-
@GetMapping("/trends")
31-
public TrendSummaryDto getTrends() {
32-
return analysisService.generateTrendSummary();
33-
}
3428
}

src/main/java/com/openelements/conduct/service/AnalysisService.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.openelements.conduct.service;
22

33
import com.openelements.conduct.api.dto.AnalysisDto;
4-
import com.openelements.conduct.api.dto.TrendSummaryDto;
54
import com.openelements.conduct.data.ViolationState;
65
import com.openelements.conduct.repository.ViolationReport;
76
import com.openelements.conduct.repository.ViolationReportRepository;
@@ -114,23 +113,6 @@ public AnalysisDto generateAnalysis() {
114113
);
115114
}
116115

117-
public TrendSummaryDto generateTrendSummary() {
118-
AnalysisDto analysis = generateAnalysis();
119-
120-
String trend = determineTrend(analysis.generalGrowthOfChecksInPercentage());
121-
String description = String.format("General growth: %.1f%%, Violations growth: %.1f%%",
122-
analysis.generalGrowthOfChecksInPercentage(),
123-
analysis.growthOfViolationCountAgainstLastWeek());
124-
125-
return new TrendSummaryDto(
126-
trend,
127-
analysis.generalGrowthOfChecksInPercentage(),
128-
description,
129-
analysis.totalNoViolationCount() + analysis.totalPossibleViolationCount() + analysis.totalViolationCount(),
130-
analysis.averageViolationCountPerDay()
131-
);
132-
}
133-
134116
private AnalysisDto createEmptyAnalysis() {
135117
return new AnalysisDto(
136118
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0, LocalDateTime.now()
@@ -165,14 +147,4 @@ private double calculateGrowthPercentage(int oldValue, int newValue) {
165147
}
166148
return ((double) (newValue - oldValue) / oldValue) * 100.0;
167149
}
168-
169-
private String determineTrend(double growthPercentage) {
170-
if (Math.abs(growthPercentage) < 10) {
171-
return "STABLE";
172-
} else if (growthPercentage > 0) {
173-
return "INCREASING";
174-
} else {
175-
return "DECREASING";
176-
}
177-
}
178150
}

0 commit comments

Comments
 (0)