PolicyEngine / policyengine-api

PolicyEngine's REST API for computing policy impacts.
GNU Affero General Public License v3.0
7 stars 19 forks source link

Add items to user_policy table #1408

Closed anth-volk closed 4 months ago

anth-volk commented 4 months ago

Fixes #1407. Fixes #1410. Fixes #1411. Fixes #1412. Fixes #1417. Fixes #1418. Fixes #1420.

This PR adds created_date, updated_date, year, geography, number_of_provisions, budgetary_cost, and api_version as required columns (except budgetary_cost, which is optional) to the user_policy table, and updates set_user_policy, get_user_policy, and the user_policy table's Pytest test to handle these additions. It also changes the response status of a POST request where a user record already exists to "ok". It creates a PUT endpoint to enable modifications of existing records using the record ID that is returned by the POST controller if the record already exists, enabling both the updating of the updated_date and api_version fields of an existing record, as well as the addition of a budgetary_cost provision following successful policy calculation on the front end.

The below video illustrates the additional new fields that comprise a record; the use of the PUT endpoint to change the API version; and the new method by which the POST endpoint handles previously created records.

https://github.com/PolicyEngine/policyengine-api/assets/14987227/d174fb3c-cef5-4bf9-93fd-fcb83e54c380

anth-volk commented 4 months ago

These tests fail because the table has not yet been updated on the deployed app. Before doing so, though, I want to confirm that we want both an updated_date and a created_date, then I will update the live table and re-run the tests.

nikhilwoodruff commented 4 months ago

Updated date and created date yes please! Thanks