JodGig Location 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 locations are migrated automatically to JodApp's Org::Outlet. Org::Outlet is simpler because this is a whole new table in JodApp so we can just sync it without checking whether data exists or not
Sync Script
...
# remember that JodGig's DB is using naive SGT time for it's datetime fields
updated_outlets = JodGig::Location.where(updated_at > last_updated_at)
outlet_upserts = updated_outlets.each do | updated_outlet |
JodGig::Location::AttributeService.execute(jodgig_location: updated_outlet)
end
Org::Outlet.upsert_all(
outlet_upserts,
unique_by: :remote_id,
record_timestamp: true
)
# write to Gig::SyncLog
...
end
Org Outlet Attributes
| Org::Outlet | JodGig::Location |
|---|---|
| id | null |
| company_id | Org::Company id that have remote_id same as jodgig_locations.company_id |
| area_user_id | null |
| address_geo_area_id | find geo_area_id by checking which address_geo_area_id is located by comparing jodgig locations' lat,lon and geo_area's boundaries |
| slug | slug |
| name | name |
| address | address |
| postal_code | postal_code |
| latitude | latitude |
| longitude | longitude |
| logo_original_filename | location_logo_filename |
| logo_s3_path | generate s3 path from jodgig bucket + folder + location logo filename |
| logo_extension | ::File.extname(location_logo_filename) |
| is_active | status |
| job_source | job_source |
| job_approval_required | job_approval_required\ |
| create_template_only | create_template_only |
| auto_job_posting | auto_job_posting |
| location_manager_can_create_job | location_manager_can_create_job |
| job_credit_deduction | job_credit_deduction |
| is_credit_negative_validation | is_credit_negative_validation |
| available_credits | available_credits |
| consumed_credits | consumed_credits |
| min_credit_limit | min_credit_limit |
| rate | rate |
| 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? |
| deleted_at | deleted_at |
| is_auto_select_applicant | is_auto_select_applicant |
| remote_id | JodGig::Location's original id |