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.
Issue: #78
Status
READY
Migrations
NO
Description
Getting workout routes with time interval Predicate starting and ending at the time of the workout doesn't explicitly return routes of this workout. We get some (or no) routes without any information in them to which workout they belong to.
Trying to get routes by providng the workout UUID returns the desired routes for each workout.
I've considered extending the current
Predicate
object andworkoutRouteQuery
function to take UUID as an additional argument, but it caused a lot of issues:Predicate
should mean that start and end date shouldn't be provided and vice versa (needed migration)Predicate
forworkoutRouteQuery
, that would either take start and end time or UUID. I've changed the map to returnMap<String, dynamic>
and swift code to take[String, Any]
arguments map, but trying to parse arguments inworkoutRouteQuery
failed when any of the parameters was null. UsingMap<String, String>
and fallbacking to an empty string when any of the parameters was null didn't help, as parsing failed when trying to parse timestamps (and although it could be checked and avoided, I think it's a pretty nasty way of doing it)Looking from another angle, when I passed the UUID to
workoutRouteQuery
, I couldn't get it to work usingor any other variations of this method I've found when reserching the topic.
The solution I've seen the most is getting routes by providing a predicate from the workout itself. This is tricky in the current codebase, because I'd need concurrency to get the workout asynchronously, then get its routes and return them. This is available in iOS 13 and forcing projects already using
workoutRouteQuery
to update the iOS version is a very bad idea.All of these reasons led me to my final decision: creating a new seperate function for getting routes by providing the workout UUID:
workoutRouteForUUIDQuery
with newUUIDPredicate
.This way, previous versions won't be affected and we'd get a new feature, available from iOS 13.
Related PRs
Not applicable.
Deploy Notes
Not applicable.
Steps to Test or Reproduce
git pull --prune
git checkout get-workout-routes-for-workout-uuid
Run example app - there is a new text button
workoutRouteForUUIDQuery
that gets workout routes for a provided UUID inworkoutRouteForUUIDQuery
method. I've added this to test whether the native connection works. Bear in mind that this package does not provide a way to save workout routes and it's tricky to provide any test data on iOS simulator, so this method will most likely return an empty list.I've also noticed that although we pass the workout UUID when saving it, it gets its own UUID later on, so setting a valid UUID in
saveWorkout
method and then trying to get it inworkoutRouteForUUIDQuery
won't work, as the UUID will be changed.Impacted Areas in Application
workoutRouteForUUIDQuery
and newUUIDPredicate
List general components of the application that this PR will affect: