@@ -495,19 +495,22 @@ public class AuctionMonitorResource {
|
||||
));
|
||||
}
|
||||
|
||||
// Add geographic insight
|
||||
// Add geographic insight (filter out null countries)
|
||||
String topCountry = auctions.stream()
|
||||
.filter(a -> a.country() != null)
|
||||
.collect(Collectors.groupingBy(AuctionInfo::country, Collectors.counting()))
|
||||
.entrySet().stream()
|
||||
.max(Map.Entry.comparingByValue())
|
||||
.map(Map.Entry::getKey)
|
||||
.orElse("N/A");
|
||||
|
||||
insights.add(Map.of(
|
||||
"icon", "fa-globe",
|
||||
"title", topCountry + " leading",
|
||||
"description", "Top performing country"
|
||||
));
|
||||
if (!"N/A".equals(topCountry)) {
|
||||
insights.add(Map.of(
|
||||
"icon", "fa-globe",
|
||||
"title", topCountry + " leading",
|
||||
"description", "Top performing country"
|
||||
));
|
||||
}
|
||||
|
||||
// Add sleeper lots insight
|
||||
long sleeperCount = lots.stream().filter(Lot::isSleeperLot).count();
|
||||
|
||||
Reference in New Issue
Block a user