Follow these steps if something looks wrong or data is missing:
sync_status.html) to see if ArcGIS and MySQL record counts match.arcgis_import.html) to confirm when the last ArcGIS → MySQL import ran and whether it had errors.raw_api_log.html) for errors when pushing data to the KBFC API.globalid matches ArcGIS records.
This system automatically transfers data from ESRI Cloud to the Local KBFC database and then uploads it to the KBFC API.
The process runs in steps: fetching new records, saving them in the database, checking for differences, and logging results.
Goal: Retrieve updated records from ESRI Cloud Feature Services.
fetch_arcgis_data() queries ESRI Cloud layers using REST API with authentication token.config.yml has survey, table_index, layer_url, and table_name.1=1) or incremental sync (EditDate >= cutoff).Goal: Map ESRI Cloud fields to MySQL table fields and normalize values.
arcgis_map_models/:
model() → defines table fields.map(row) → transforms ESRI Cloud record into MySQL-ready dict.safe_str, safe_int, convert_to_api_iso_datetime) ensure consistent data formats.Goal: Sync ESRI Cloud data to MySQL tables.
insert_records() checks if a record exists in MySQL by globalid.Goal: Verify MySQL table matches ESRI Cloud source.
audit_sync_status() compares record counts and finds missing/orphaned records.audit_summaries.Goal: Remove MySQL rows that no longer exist in ESRI Cloud.
cleanup_orphans.py checks all tables for records in MySQL but not in ESRI Cloud.globalid.Goal: Provide visibility of sync operations.
logs/main.log.convert_log_to_html() → Converts ANSI logs to HTML (logs/arcgis_import.html).generate_import_summary_html() → Creates summary page showing last sync time, error count, sync status.generate_log_summary() → Generates combined HTML summary for Local KBFC DB → Collaborative KBFC DB uploads.Goal: Push MySQL data to KBFC API.
/mrrcaptures, /eventlog, /effort).event_log table in SQLite.Goal: Provide a single entry point for monitoring.
kbfc_log_reader.html → Upload logs and errors (Local KBFC DB → Collaborative KBFC DB).arcgis_import.html → ESRI Cloud → Local KBFC DB log.raw_api_log.html → Raw API call log.sync_status.html → Table-by-table sync audit summary.import_summary.html → High-level ESRI Cloud → Local KBFC DB sync status.