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

lts/enh/reducing-delay-in-sending-lts-trigger-fcm-for-new-ride #139

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/location_tracking_service/src/common/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ pub struct DriverAllDetails {
pub driver_last_known_location: DriverLastKnownLocation,
pub blocked_till: Option<TimeStamp>,
pub stop_detection: Option<StopDetection>,
pub ride_status: Option<RideStatus>,
// pub travelled_distance: Option<Meters>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ pub async fn driver_block_till(
&details.driver_last_known_location.timestamp,
&Some(request_body.block_till),
details.stop_detection,
&None::<RideStatus>,
// travelled_distance.to_owned(),
)
.await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ async fn process_driver_locations(
&latest_driver_location_ts,
&None::<TimeStamp>,
stop_detection,
&driver_ride_status,
// travelled_distance.to_owned(),
)
.await?;
Expand Down Expand Up @@ -497,7 +498,13 @@ pub async fn track_driver_location(
.await?
.ok_or(AppError::DriverLastKnownLocationNotFound)?;

let delay_time = Utc::now().timestamp() - data.driver_location_delay_in_sec;
let delay_time = match driver_location_details.ride_status {
Some(RideStatus::NEW) => {
Utc::now().timestamp() - data.driver_location_delay_for_new_ride_sec
}
_ => Utc::now().timestamp() - data.driver_location_delay_in_sec,
};

let TimeStamp(driver_update_time) =
driver_location_details.driver_last_known_location.timestamp;
if driver_update_time.timestamp() < delay_time {
Expand Down
4 changes: 4 additions & 0 deletions crates/location_tracking_service/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct AppConfig {
pub log_unprocessible_req_body: Vec<String>,
pub max_allowed_req_size: usize,
pub driver_location_delay_in_sec: i64,
pub driver_location_delay_for_new_ride_sec: i64,
pub trigger_fcm_callback_url: String,
pub apns_url: String,
}
Expand Down Expand Up @@ -119,6 +120,7 @@ pub struct AppState {
pub log_unprocessible_req_body: Vec<String>,
pub request_timeout: u64,
pub driver_location_delay_in_sec: i64,
pub driver_location_delay_for_new_ride_sec: i64,
pub trigger_fcm_callback_url: Url,
pub apns_url: Url,
}
Expand Down Expand Up @@ -225,6 +227,8 @@ impl AppState {
blacklist_merchants,
stop_detection: app_config.stop_detection,
driver_location_delay_in_sec: app_config.driver_location_delay_in_sec,
driver_location_delay_for_new_ride_sec: app_config
.driver_location_delay_for_new_ride_sec,
trigger_fcm_callback_url: Url::parse(app_config.trigger_fcm_callback_url.as_str())
.expect("Failed to parse fcm_callback_url."),
apns_url: Url::parse(app_config.apns_url.as_str()).expect("Failed to parse apns_url."),
Expand Down
2 changes: 2 additions & 0 deletions crates/location_tracking_service/src/redis/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ pub async fn set_driver_last_location_update(
last_location_ts: &TimeStamp,
blocked_till: &Option<TimeStamp>,
stop_detection: Option<StopDetection>,
ride_status: &Option<RideStatus>,
) -> Result<DriverLastKnownLocation, AppError> {
let last_known_location = DriverLastKnownLocation {
location: Point {
Expand All @@ -315,6 +316,7 @@ pub async fn set_driver_last_location_update(
driver_last_known_location: last_known_location.to_owned(),
blocked_till: blocked_till.to_owned(),
stop_detection,
ride_status: ride_status.to_owned(),
// travelled_distance: Some(travelled_distance),
};

Expand Down
1 change: 1 addition & 0 deletions dhall-configs/dev/location_tracking_service.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ in {
log_unprocessible_req_body = ["UNPROCESSIBLE_REQUEST", "REQUEST_TIMEOUT", "LARGE_PAYLOAD_SIZE", "HITS_LIMIT_EXCEEDED"],
max_allowed_req_size = 512000, -- 500 KB
driver_location_delay_in_sec = 60,
driver_location_delay_for_new_ride_sec = 10,
trigger_fcm_callback_url = "http://127.0.0.1:8016/internal/driverInactiveFCM",
apns_url = "https://api.sandbox.push.apple.com:443",
}