JodGig Company Sync
Sync Process
we'll schedule the sync job to run DAILY and write it to Gig::SyncLog.
We'll sync using upsert to ensure that newly created companies are migrated automatically to JodApp's Org::Company. We need to ensure we're not overwriting existing company in JodApp with data from JodGig
Sync Script
...
# remember that JodGig's DB is using naive SGT time for it's datetime fields
updated_companies = JodGig::Company.where(updated_at > last_updated_at)
company_upserts = updated_companies.each do | updated_company |
JodGig::Company::AttributeService.execute(jodgig_company: updated_company)
end
Org::Company.upsert_all(
company_upserts,
unique_by: :remote_id,
record_timestamp: true
)
# write to Gig::SyncLog
...
end
Org Company Attributes
| Org::Company | JodGig::Company |
|---|---|
| id | null |
| parent_company_id | null |
| country_id | hard code to Singapore's geo_country id in jodapp |
| name | name |
| primary_address | address |
| postal_code | extract postal code from address |
| use HQ user's email address if available, else use placeholder | |
| website_url | website_url |
| description | description |
| registration_no | registration_no |
| is_enabled | status |
| created_by | null, @todo: update this after user is migrated |
| updated_by | null, @todo: update this after user is migrated |
| created_at | created_at |
| updated_at | updated_at |
| is_deleted | deleted_at.present? |
| is_deleted_at | deleted_at |
| address_geo_area_id | determine general geo_area based on address |
| uuid | SecureRandom.uuid |
| logo_original_filename | company_logo_filename |
| logo_s3_path | generate_s3_path for jodgig bucket |
| logo_extension | ::File.extname(company_logo_filename) |
| slug | slug |
| remote_id | JodGig::Company's original d |