I hereby claim:
- I am eboswort on github.
- I am eboswort (https://keybase.io/eboswort) on keybase.
- I have a public key ASDkUdR5wcT0ivrk2ebEc2DGsmO_1r0Qc5mUMNGcO7yfrQo
To claim this, I am signing this object:
# Here's the migration to pull each shipment_event into its own row in a view | |
class CreateTrackingEventsView < ActiveRecord::Migration | |
def change | |
sql = %{ | |
SELECT | |
json_array_elements(tracking_info->'shipment_events') as info, | |
number as shipment_number | |
FROM shipments where (tracking_info->'shipment_events') IS NOT NULL | |
} | |
# Here's an example tracking json object with shipment_events | |
example_tracking_json = { | |
"status": "delivered", | |
"shipment_events":[ | |
{ | |
"name":"BILLING INFORMATION RECEIVED", | |
"time":"2015-07-23T17:22:59.000Z", ... | |
}, ... | |
{ | |
"name": "THE RECEIVER WAS NOT AVAILABLE AT THE TIME OF THE FIRST DELIVERY ATTEMPT.", |
# We pulled out the scheduled delivery date to render in our order status page | |
shipment.tracking_info['scheduled_delivery_date'] | |
# We created some scopes to keep track of shipments in different stages of delivery | |
scope :delivered, -> { where("tracking_info->>'status' = 'delivered'") } | |
# Syntax could get a little ugly with slightly more complicated queries | |
Shipment.where("promised_arrival_date < (tracking_info->>'actual_delivery_date')::date") | |
# We got it working with ransack, a gem we use for creating search forms |
I hereby claim:
To claim this, I am signing this object: