Bulk Pack Processing v2
Field data schem
Wallet registrations need to be stored in the field data schema in the wallet_registrations table, but they also need to be used to upsert (create or update) grower account records in the treetracker API. A wallet registration also needs the grower account id field populated.
Bulk pack transformer calls PUT on grower_account in treetracker API for grower account with identifier that matches wallet
If account exists, update
Only update the name, phone, and email for now
Else, insert
Insert identifier, name, phone, email, and photo
POST to /planter path on bulk-pack-transformer-1 to populate legacy schema
Populate grower account id in wallet registration data, and POST into field data api
If wallet registration id is already present, field data api will do nothing (return 200)
Return 200
device configuration records are simply inserted in v2, but in v1 they were upserted.
POST device configuration payload to bulk-pack-transformer-1
bulk-pack-transformer-1 returns 200 if already present
POST device configuration payload to field data API
field data API returns 200 if already present
Return 200
session does not exist in the v1 bulk-pack-transformer.
POST to session path on field data API
field data API returns 200 if already present
Return 200
POST capture data to bulk-pack-transformer-1
If data exists this API returns 200, else a new record is inserted
This API also propagates the record to field data API, where a queue message is emitted
POST capture data to field data API
Since step 1 already propagated to this API, a 200 should be returned based on uuid
Since 200 is returned, queue message should not re-emitted
Session
track_url
organization
Wallet Registration
phone or email is nullable, but not both
Raw Capture
session_id is nullable for v1 endpoints only
reference_id
note
extra_attributes
rejection_reason
Device Configuration
No nullable fields
Insert 'tree' as 'capture' will fail until corresponding device and registration records have been inserted, because there's no session Once device and registration records are inserted, then it is possible to insert a session id using SESSION UUID = device_identifier + planter_identifier In v2 bulk pack endpoint /v1/tree is responsible for ensuring that the session record exists for a v1 tree. This session can then be used as the session for inserting the v1 'tree' record as a v2 'capture' record
process sends tree record to /v1/tree in v2
v2 calculates SESSION UUID = device_identifier + planter_identifier using uuid-string
v2 checks for a session that matches this
If no session exists, it looks up device_configuration_id and wallet_registration_id using device_identifier and planter_identifier, and if they exist it creates a session record. If they don't exist yet, it fails until next time.
Assuming a session exists or was inserted in (4), we can now insert the capture record using his session uuid.
Old versions:
greenstand/bulk-pack-processor:1.2.7
greenstand/bulk-pack-transformer:1.6.2
Bulk Pack Format v2 :