The implementation is similar to the existing reliance on the ConCache ETS memory store, i.e the workflow do_remove at /api/workflows/:id/remove which wrapped the RecentlyRetired ConCache store.
It will raise an error if the workflow_id is not a string or integer that can be cast to an integer. It will check and cast all subject_ids to valid integers before storing in the user cache seen_ids. If any subject_id can not be cast it will return a 422 with a message invalid subject id supplied, must be a valid integer.
I tried to add better incoming param schema checking but it wasn't nice and added a dep, i left it as it is because it's how it already is combined with the fact it is an internal API and the manta of erlang is fail fast if you are going to fail. If this becomes an issue we can provide better param validation later.
Finally the concache is one big state store shared between tests, i couldn't get the store to reset the cache between tests so came up with a way to reset it manually. Not super happy with it but it works for now.
I might suggest an additional spec that tests the union of existing and updated subject ids, in addition to testing deduplication when the existing set is already fully included.
Closes #85 by adding an API to update a user's subjects
seen_ids
listAllow a cached user to have their
seen_ids
updated via PUT api endpoints that accepts JSON encoded data payloads:/api/users/#{user_id}/add_seen_subjects
{ workflow_id: ${workflow_id}, subject_ids: [1,2,3]}
/api/users/#{user_id}/add_seen_subject
{ workflow_id: ${workflow_id}, subject_id: 4}
The implementation is similar to the existing reliance on the ConCache ETS memory store, i.e the workflow
do_remove
at/api/workflows/:id/remove
which wrapped the RecentlyRetired ConCache store.It will raise an error if the workflow_id is not a string or integer that can be cast to an integer. It will check and cast all subject_ids to valid integers before storing in the user cache
seen_ids
. If any subject_id can not be cast it will return a 422 with a messageinvalid subject id supplied, must be a valid integer
.I tried to add better incoming param schema checking but it wasn't nice and added a dep, i left it as it is because it's how it already is combined with the fact it is an internal API and the manta of erlang is fail fast if you are going to fail. If this becomes an issue we can provide better param validation later.
Finally the concache is one big state store shared between tests, i couldn't get the store to reset the cache between tests so came up with a way to reset it manually. Not super happy with it but it works for now.