@@ -65,21 +65,20 @@ public WeatherSummary getWeatherSummary(Long id, int date, int hour) {
6565 TideObservatory tideObservatory = TideObservatory .findNearest (place .getLatitude (), place .getLongitude ());
6666 List <TideRecord > tideRecords = tideRepository .findAllByDatesAndTideObservatory (first , last , tideObservatory );
6767
68- List <String > stringWarnings = new ArrayList <>();
69- stringWarnings .addAll (warningRepository .findAllByRegionAndStatusIn (place .getLandRegion (),
70- List .of (WarningStatus .ISSUED , WarningStatus .MODIFIED )).stream ()
71- .map (warning -> warning .getCode ().getDescription () + warning .getLevel ().getDescription ())
72- .toList ());
73- stringWarnings .addAll (warningRepository .findAllByRegionAndStatusIn (place .getSeaRegion (),
74- List .of (WarningStatus .ISSUED , WarningStatus .MODIFIED )).stream ()
75- .map (warning -> warning .getCode ().getDescription () + warning .getLevel ().getDescription ())
76- .toList ());
68+ List <WarningStatus > statuses = List .of (WarningStatus .ISSUED , WarningStatus .MODIFIED );
69+ List <String > stringWarningList = warningRepository .findAllByPlaceRegionAndStatusIn (
70+ place .getLandRegion (), place .getSeaRegion (),
71+ statuses ).stream ().map (Warning ::getWarningMessage )
72+ .toList ();
73+
74+ List <String > recommendActivities =
75+ stringWarningList .isEmpty () ? getRecommendActivities (weather , tideRecords ) : new ArrayList <>();
7776
7877 int tidePercentage = calculateTidePercentage (tideRecords );
7978 return WeatherSummary .of (
8079 weather ,
81- stringWarnings ,
82- getRecommendActivities ( weather , tideRecords ) ,
80+ stringWarningList ,
81+ recommendActivities ,
8382 tidePercentage
8483 );
8584 }
0 commit comments