platelet-app / platelet

Dispatch system for emergency volunteer couriers.
https://platelet.app
Apache License 2.0
38 stars 10 forks source link

Selective filtering for riders in syncExpressions #73

Closed duckbytes closed 1 year ago

duckbytes commented 2 years ago

For users with only the rider role, their device should only sync tasks that are assigned to them. This will save on bandwidth and loading times.

src/redux/WhoamiSaga.js line 105 uses syncExpressions to selectively filter data that is synced.

There might be a way of configuring this to not sync tasks that aren't assigned to the user.

If the user has the coordinator role as well, all data should be synced.

duckbytes commented 2 years ago

An easier way might be to only sync data for tasks that have an uncompleted status (new, active, picked up, dropped off) or only tasks that are newer than a week but have a complete status (completed, rejected, cancelled, abandoned). Anything else is ignored.

This is relatively easy to configure for Task records. It's more difficult to know how to account for TaskAssignee records.

When Tasks are selectively synced for the past week, datastore throws errors because of missing non-nullable records on TaskAssignees.

Figuring out how to synchronise these may mean adding fields that have to be maintained on the client.

Could add a taskCompleted int value on the TaskAssignee record along with a dateTaskCreated record that copies a dateCreated record from Task.

Not sure how reliable this implementation would be.