platelet-app / platelet

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

Archive script for backend #134

Closed duckbytes closed 1 year ago

duckbytes commented 1 year ago

Adds a lambda function that runs daily at 3am.

This function takes any tasks with a completed status (COMPLETED, CANCELLED, ABANDONED, REJECTED) and if they are older than a week according to createdAt are updated to be archived.

It also flags any associated comments, items, assignments and unlisted locations as archived.

On the client side, DataStore is configured to not sync any items that are archived.

This should greatly reduce the initial sync time on opening the app, as only the last weeks worth of data and uncompleted tasks are downloaded.

TODO:

It's especially important that no further users are assigned to an archived task, as the relations are non-nullable. This could break sync for users. Some care needs to be taken to prevent that from happening.

codecov-commenter commented 1 year ago

Codecov Report

Merging #134 (86d8237) into master (94b9f67) will decrease coverage by 0.01%. The diff coverage is 65.71%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #134      +/-   ##
==========================================
- Coverage   59.61%   59.60%   -0.01%     
==========================================
  Files         304      304              
  Lines       10010    10019       +9     
  Branches     2539     2534       -5     
==========================================
+ Hits         5967     5972       +5     
- Misses       3678     3681       +3     
- Partials      365      366       +1     
Impacted Files Coverage Δ
src/graphql/mutations.js 100.00% <ø> (ø)
src/graphql/subscriptions.js 0.00% <ø> (ø)
src/models/schema.js 100.00% <ø> (ø)
src/redux/whoami/whoamiSagas.js 10.71% <0.00%> (-0.40%) :arrow_down:
...hboard/components/RiderConfirmationHomeContents.js 0.00% <0.00%> (ø)
src/scenes/Dashboard/components/TaskItem.js 88.46% <ø> (ø)
...oard/utilities/generateMultipleAssignmentModels.ts 87.17% <0.00%> (ø)
src/scenes/Statistics/utilities/getStats.js 6.97% <0.00%> (ø)
src/utilities/determineTaskStatus.ts 97.22% <ø> (ø)
src/scenes/Dashboard/utilities/getAllMyTasks.ts 66.66% <66.66%> (-1.34%) :arrow_down:
... and 8 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

duckbytes commented 1 year ago

Added a migration script that back-populates the archived field on Task, Comment, Deliverable, TaskAssignee and Location to 0.

This script is set to run once on 3rd of April 2023, but that could be changed.

DataStore is not configured to filter archived items. The code will need to be updated and changed once the migration script has run.

There isn't a reliable way to prevent users from assigning a user to a task that has been archived. For now I've made the Task field not required and added some additional filtering on the front end.