-
Notifications
You must be signed in to change notification settings - Fork 27
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
Replay time ordering #405
Merged
Merged
Replay time ordering #405
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
83ace70
Include locationMs, and replayRequestMs
lmeier 233ccc2
Ensure updatedAtMsDiff is correct
lmeier 3b84c99
bump version
lmeier 2e7bbbd
fix ordering
lmeier 109283d
correct version
lmeier 9ee710f
Add logging of visits
lmeier dcd18b8
simplify to just updatedAtMsDiff
lmeier 531feb1
fix lint error
lmeier ce6fb3a
always include updatedAtMsDiff
lmeier 19dfb83
log cleanup
lmeier b6a5ee8
Merge branch 'master' into replayTimestamps
lmeier cc8b817
timeInMs --> locationMs, don't send updatedAtMsDiff if verified
lmeier 161cba4
extra bracket
lmeier 8d7bdd6
nit
lmeier a214c59
Merge branch 'master' into replayTimestamps
KennyHuRadar 2d22f43
not verified or not foreground
lmeier 9b1432c
version bump
KennyHuRadar a3818cf
don't conditionalize for verified
lmeier 63d548d
Revert "log cleanup"
lmeier 04bae9e
don't conditionalize updatedAtMsDiff at all
lmeier 910d489
make api helper logic more clear
lmeier ad35612
Merge branch 'master' into replayTimestamps
KennyHuRadar 1cd42d9
Reformat to more closely match android impl
lmeier b138b15
Make nil check explict
lmeier 1f5c6d0
put behind a feature setting
lmeier 1c7ca58
Typo
lmeier d3c24f7
Merge branch 'master' into replayTimestamps
KennyHuRadar f06ebe5
bump version
KennyHuRadar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,9 +67,39 @@ - (void)requestWithMethod:(NSString *)method | |
} | ||
|
||
if (params) { | ||
[req setHTTPBody:[NSJSONSerialization dataWithJSONObject:params options:0 error:NULL]]; | ||
NSNumber *prevUpdatedAtMsDiff = params[@"updatedAtMsDiff"]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that we're collecting |
||
NSArray *replays = params[@"replays"]; | ||
if (prevUpdatedAtMsDiff || replays) { | ||
NSMutableDictionary *requestParams = [params mutableCopy]; | ||
long nowMs = (long)([NSDate date].timeIntervalSince1970 * 1000); | ||
NSNumber *locationMs = params[@"locationMs"]; | ||
|
||
if (locationMs != nil && prevUpdatedAtMsDiff != nil) { | ||
long updatedAtMsDiff = nowMs - [locationMs longValue]; | ||
requestParams[@"updatedAtMsDiff"] = @(updatedAtMsDiff); | ||
} | ||
|
||
if (replays) { | ||
NSMutableArray *updatedReplays = [NSMutableArray arrayWithCapacity:replays.count]; | ||
for (NSDictionary *replay in replays) { | ||
NSMutableDictionary *updatedReplay = [replay mutableCopy]; | ||
NSNumber *replayLocationMs = replay[@"locationMs"]; | ||
if (replayLocationMs != nil) { | ||
long replayUpdatedAtMsDiff = nowMs - [replayLocationMs longValue]; | ||
updatedReplay[@"updatedAtMsDiff"] = @(replayUpdatedAtMsDiff); | ||
} | ||
[updatedReplays addObject:updatedReplay]; | ||
} | ||
requestParams[@"replays"] = updatedReplays; | ||
} | ||
lmeier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[req setHTTPBody:[NSJSONSerialization dataWithJSONObject:requestParams options:0 error:NULL]]; | ||
} else { | ||
[req setHTTPBody:[NSJSONSerialization dataWithJSONObject:params options:0 error:NULL]]; | ||
} | ||
} | ||
|
||
|
||
NSURLSessionConfiguration *configuration; | ||
if (extendedTimeout) { | ||
configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ok so I guess the approach now is:
• change
foreground = true
to also useupdatedAtMsDiff
(for consistency? I might have been the one to bring this up?)• Don't special case
verified = true
on the client side, handle it differently on the server sideIf we decided not to change
foreground = true
toupdatedAtMsDiff
, would the other changes toupdatedAtMsDiff
in these PRs be enough to fix the bug? Or is the inconsistent behavior betweenforeground = true
andforeground = false
causing a problem?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.
Yes, for three reasons:
updatedAtMsDiff
causes a problem when a foreground location gets forced to server time while background locations are adjusted perupdatedAtMsDiff
, leading to inconsistent ordering (a subsequent background location can be brought erroneously before the foreground location by theupdatedAtMsDiff
adjustment). So no, the otherupdatedAtMsDiff
changes would be not sufficient to fully fix the bug.now
timestampThere 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.
Correct, per slack conversation. I'll link in #mobile