Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main b 18911 gun safe backend #12557

Merged
merged 16 commits into from
May 10, 2024
Merged

Conversation

brooklyn-welsh
Copy link
Contributor

B-18910

INT PRs

#12511 #12440

Summary

This branch adds changes to the backend to allow the app to track whether or not a customer has an entitlement to ship a gun safe. Currently the govt. just want's a flag to denote whether this is true or false, no weight calculations/fields have been added.

It also makes the gunSafe entitlement visible to the prime on the backend.

How to test

First PR / general backend

  1. Get the Order ID of an order through the web tools, easiest way is to access the "Edit orders" screen of a move then hit F12, you should see a uuid near the bottom of the "Network" tab, you'll want the top-level ID from this JSON set.
  2. Use Postman to access the GHC/Office API at {{baseUrl}}/counseling/orders/:orderID/allowances and fill in the order ID in the URL.
  3. Use the Postman Interceptor or set your cookie values as needed, you'll also need to set a X-CSRF-Token value in the request headers to the value of the masked_gorilla cookie.
  4. For the body, use { "gunSafe": true } , Send and make sure you get a 200 OK response.
  5. Either get the entitlement ID from the web browser tools, or open DBeaver (or any database tool), go to the orders table and find your order with the UUID you noted, go to the entitlement_id column and click the link (in DBeaver, small box to the left of the actual value), to open the appropriate entitlement in the entitlements table.
  6. Scroll to the end where you should see a "gun_safe" field, which should now be checked.
  7. If you send another Postman request with a body of "{ gunSafe: false }", you should be able to refresh DBeaver and see the value is now false.

Second PR / Make Available To Prime

  1. Find a move ID for any available to Prime move in the database using DBeaver, and edit it's gun safe flag to "true". Alternatively, if you want to use postman, using the move ID, issue a PATCH request with "gunSafe: true" in the body to "{{baseUrl}}/move-task-orders/:moveTaskOrderID/post-counseling-info".

  2. Using Postman, access the Prime API and hit the {{baseUrl}}/move-task-orders/:moveID GET endpoint after getting the move id from the Network devtools tab or from a database explorer, inside the "entitlements" object, you should see a "gunSafe" boolean.

You can also verify via Postman that any API endpoint that uses an "Order" object now has a "gunSafe" boolean inside its nested "entitlements" object.

Note: You'll only see the gunSafe field in the object if gunSafe is set to true, otherwise it is not present.

Copy link
Contributor

@WeatherfordAaron WeatherfordAaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@JamesHawks224
Copy link
Contributor

verify rpt:
B18911-12557.verify_rpt.txt

there were diffs

@brooklyn-welsh brooklyn-welsh marked this pull request as ready for review May 6, 2024 18:39
@brooklyn-welsh brooklyn-welsh requested a review from a team as a code owner May 6, 2024 18:39
Copy link
Contributor

@JamesHawks224 JamesHawks224 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

-- COALESCE makes sure that any currently NULL gun_safe values are converted to false before setting to NOT NULL.
ALTER TABLE entitlements
ALTER COLUMN gun_safe TYPE boolean USING (COALESCE(gun_safe, false)),
ALTER COLUMN gun_safe SET DEFAULT false,
Copy link
Contributor

@deandreJones deandreJones May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is taken care of in the above migration file?
ALTER COLUMN gun_safe SET DEFAULT false,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in my original migration that added the gun_safe column, it could be either T, F, or null, but after finding that null would error out in some cases, I added this migration to edit the table so that it's only true or false, since that also makes sense logically anyway. Now it defaults to false, and is only set to true if the customer/office user flags that a gun safe is allowed.

@JamesHawks224 JamesHawks224 merged commit 528d5ae into main May 10, 2024
42 checks passed
@JamesHawks224 JamesHawks224 deleted the MAIN-B-18911-gun-safe-backend branch May 10, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ByteSize M&Ms Team ByteSized M&Ms MAIN
Development

Successfully merging this pull request may close these issues.

4 participants