Skip to content

Commit

Permalink
improvement(CheckMonitoredTrip): Place initial reminder text at top o…
Browse files Browse the repository at this point in the history
…f notifications.
  • Loading branch information
binh-dam-ibigroup committed Nov 28, 2023
1 parent 2cfff4a commit e8adc1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public TripMonitorNotification(NotificationType type, String body) {
this.body = body;
}

public int sortOrder() {
return type == NotificationType.INITIAL_REMINDER ? -100 : 0;
}

public static TripMonitorNotification createAlertNotification(
Set<LocalizedAlert> previousAlerts,
Set<LocalizedAlert> newAlerts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -423,10 +424,13 @@ private void sendNotifications() {
LOG.info("Last notifications match current ones. Skipping notify.");
return;
}

Map<String, Object> templateData = Map.of(
"tripId", trip.id,
"tripName", trip.tripName,
"notifications", notifications.stream()
// Make certain notifications, such as the initial reminder one, appear on top.
.sorted(Comparator.comparingInt(TripMonitorNotification::sortOrder))
.map(notification -> notification.body)
.collect(Collectors.toList())
);
Expand Down

0 comments on commit e8adc1b

Please sign in to comment.