-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Post deviated trip notification #260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, but pretty solid so far.
/** | ||
* Get users whose last trip survey notification was at least a week ago. | ||
*/ | ||
public static List<OtpUser> getUsersWithNotificationsOverAWeekAgo() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is or should there be a option to opt-out of receiving surveys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No opt-out of post-travel surveys at the moment.
@@ -84,6 +85,16 @@ public static void main(String[] args) throws IOException, InterruptedException | |||
1, | |||
TimeUnit.MINUTES | |||
); | |||
|
|||
// Schedule recurring job for post-trip surveys, once every few hours | |||
// TODO: Determine whether this should go in some other process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the trigger location is fine. Perhaps follow the approach of ConnectedDataManager.scheduleTripHistoryUploadJob();
and have the schduler in the class. It might also be benefical to have the ability to disable this via a config property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binh-dam-ibigroup thoughts on these two points?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd have to rethink where to run periodic tasks.
src/main/java/org/opentripplanner/middleware/OtpMiddlewareMain.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opentripplanner/middleware/models/OtpUser.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opentripplanner/middleware/triptracker/TripSurveySenderJobTest.java
Show resolved
Hide resolved
…hold to select trips.
… trip completion.
… delete FTL template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Some minor points to consider, but approving.
@@ -84,6 +85,16 @@ public static void main(String[] args) throws IOException, InterruptedException | |||
1, | |||
TimeUnit.MINUTES | |||
); | |||
|
|||
// Schedule recurring job for post-trip surveys, once every few hours | |||
// TODO: Determine whether this should go in some other process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@binh-dam-ibigroup thoughts on these two points?
@@ -91,4 +98,40 @@ public void updateNotificationMessage(String routeId, String body) { | |||
busNotificationMessages | |||
); | |||
} | |||
|
|||
/** The sum of the deviations for all tracking locations that have it. */ | |||
public double computeTotalDeviation() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method has no usages. Remove?
@@ -152,6 +152,8 @@ private static EndTrackingResponse completeJourney(TripTrackingData tripData, bo | |||
trackedJourney.end(isForciblyEnded); | |||
Persistence.trackedJourneys.updateField(trackedJourney.id, TrackedJourney.END_TIME_FIELD_NAME, trackedJourney.endTime); | |||
Persistence.trackedJourneys.updateField(trackedJourney.id, TrackedJourney.END_CONDITION_FIELD_NAME, trackedJourney.endCondition); | |||
trackedJourney.longestConsecutiveDeviatedPoints = trackedJourney.computeLargestConsecutiveDeviations(); | |||
Persistence.trackedJourneys.updateField(trackedJourney.id, TrackedJourney.LONGEST_CONSECUTIVE_DEVIATED_POINTS_FIELD_NAME, trackedJourney.longestConsecutiveDeviatedPoints); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Wrap this line.
Locale locale = I18nUtils.getOtpUserLocale(otpUser); | ||
String tripTime = DateTimeUtils.formatShortDate(trip.itinerary.startTime, locale); | ||
String body = String.format( | ||
org.opentripplanner.middleware.i18n.Message.TRIP_SURVEY_NOTIFICATION.get(locale), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Consider a static import.
location.tripStatus = d == null | ||
? null | ||
: d == 1 | ||
? TripStatus.DEVIATED | ||
: TripStatus.ON_SCHEDULE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant!
src/test/java/org/opentripplanner/middleware/triptracker/TripSurveySenderJobTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 This looks good.
…ious notifications=.
@br648 and @JymDyerIBI I added a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Changes look good.
Checklist
dev
before they can be merged tomaster
)Description
This PR sets up a job to send post-trip surveys for users who took trips the day before.
The same notification endpoint will be used for both trip monitoring notifications and trip survey notifications post travel.
Blockers:
Need a modified or new push notifications endpoint for trip surveys.