Added django simple history models, and added modified_since param #147
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.
I've added a Django extension called django_simple_history to help track DB changes. This library adds a changelog table for each core model. The changelog table records create, update, and delete actions on those tables, including which fields were changed, by who, and when.
I've also added an optional query parameter called "modified_since" to the data management API's GET things and datastreams endpoints. If left null, the request should function normally. If a valid datetime is entered, HydroServer will return only records that have been modified since the given datetime based on what's been entered into the changelog table.
There is some code I added and then commented out related to handling HEAD requests and "Last-Modified" and "Is-Modified-Since" headers. We may want to add it back in for additional caching functionality in the future, but at the moment, Django Ninja isn't compatible with several important Django decorators such as "conditional". Apparently, Django Ninja v1.0 will support these decorators, so we may want to revisit that later.
I've removed query count checks in create, update, and delete tests. These were failing frequently due to varying savepoint queries. We really only care about query counts on GET requests.
The django_simple_history models should provide us a framework for adding "modified_since" query parameters to other endpoints later on if we need them. We can also use these tables for an auditing feature. We should consider adding some kind of automated cleanup script to these tables that drops old records. For caching, it's unlikely we'll ever care about data in these tables that's more than 24 hours old. For auditing functionality, we can archive older data to an external location such as S3.