Skip to content
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

Draft
wants to merge 21 commits into
base: dev
Choose a base branch
from

Conversation

binh-dam-ibigroup
Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup commented Oct 9, 2024

Checklist

  • Appropriate branch selected (all PRs must first be merged to dev before they can be merged to master)
  • Any modified or new methods or classes have helpful JavaDoc and code is thoroughly commented
  • [na] The description lists all applicable issues this PR seeks to resolve
  • [na] The description lists any configuration setting(s) that differ from the default settings
  • All tests and CI builds passing

Description

This PR sets up a job to send post-trip surveys for users who took trips the day before.

Blockers:

  • Need a modified or new push notifications endpoint for trip surveys.

@binh-dam-ibigroup binh-dam-ibigroup added the BLOCKED Blocked (waiting on another PR to be merged) label Oct 9, 2024
Copy link
Contributor

@br648 br648 left a 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() {
Copy link
Contributor

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?

Copy link
Collaborator Author

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.
Copy link
Contributor

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.

Scheduler.scheduleJob(
tripSurveySenderJob,
0,
12,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to send notifications potentially in the early hours of the morning? Do we care? Might get a better response in working hours.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Morning local time sounds good. Do you know how to do that with this scheduler?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workout the diff between now and the next 9am in seconds and use that as the initial delay. Time unit used by the scheduler would have to be seconds.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change on when notifications are sent: within 20-30 minutes of trip completion.

@@ -76,6 +77,9 @@ public enum Notification {
/** Whether to store the user's trip history (user must opt in). */
public boolean storeTripHistory;

/** When the last post-trip survey notification was sent. */
public Date lastTripSurveyNotificationSent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only referenced in tests. I think it is updated via the field reference above, so is required at a DB level?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this field is needed to keep track of when a post-travel notification was sent when subsequent trips are completed.

}

@Test
void canGetUsersWithNotificationsOverAWeekAgo() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails for me: expected: <2> but was: <3>. Perhaps OS?

@br648 br648 assigned binh-dam-ibigroup and unassigned br648 Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLOCKED Blocked (waiting on another PR to be merged)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants