Skip to content

Conversation

@makrsmark
Copy link
Contributor

@makrsmark makrsmark commented Jan 22, 2026

convert csvs from https://ourairports.com/data/ to json

Summary by CodeRabbit

  • Chores
    • Added automated airport and frequency data synchronization with daily scheduled updates, pull-request validation, and manual trigger support.
  • New Features
    • Added a data-refresh utility that downloads public CSV datasets and generates updated JSON outputs for use by the application.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds a GitHub Actions workflow that runs a new Ruby script to fetch airport and frequency CSVs, convert them to JSON, and commit the generated JSON files on a schedule, manual dispatch, and non-PR triggers.

Changes

Cohort / File(s) Summary
Workflow Configuration
​.github/workflows/update-ourairports.yml
New GitHub Actions workflow "Update Airports and Frequencies" triggered on pull_request (specific paths), daily cron, and workflow_dispatch. Runs checkout, Ruby setup, installs deps, executes scripts/ourairports, and conditionally commits *.*json using EndBug/add-and-commit (skips commit for PR events).
Data Processing Script
scripts/ourairports
New Ruby script that downloads two CSV datasets over HTTP, parses them with the CSV library, maps rows into airports and airport_frequencies JSON schemas, and writes both pretty and compact JSON outputs to configured file paths.

Sequence Diagram(s)

sequenceDiagram
    participant Scheduler as GitHub Actions (cron / dispatch)
    participant Repo as Repository (workflow)
    participant Runner as Runner (ubuntu-latest)
    participant Remote as OurAirports CSV Host
    participant Commit as Git Commit Action

    Scheduler->>Repo: trigger workflow (cron / dispatch / PR)
    Repo->>Runner: start job
    Runner->>Runner: checkout code\nsetup Ruby\ninstall deps
    Runner->>Remote: HTTP GET airports.csv
    Remote-->>Runner: airports CSV
    Runner->>Remote: HTTP GET frequencies.csv
    Remote-->>Runner: frequencies CSV
    Runner->>Runner: parse CSV -> build JSON files
    Runner->>Commit: run EndBug/add-and-commit (if not PR)
    Commit-->>Repo: commit JSON files (if changes)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped to fetch the skies so wide,

CSVs turned JSON, neat inside.
A nightly nibble, code in flight,
Commits arrive by morning light. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding a new Ruby script that syncs OurAirports data by converting CSVs to JSON.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a Ruby script to synchronize airport and frequency data from OurAirports.com, converting CSV data to JSON format with scheduled automated updates.

Changes:

  • Creates a Ruby script that downloads airport and frequency CSVs from OurAirports, enriches the data with ISO country/region information, and outputs both compact and pretty-printed JSON files
  • Adds a GitHub Actions workflow to run the sync script daily at 13:00 UTC and automatically commit the updated JSON files

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/ourairports Ruby script that fetches CSV data from OurAirports, maps fields to JSON structure with country enrichment, and writes output files
.github/workflows/update-ourairports.yml GitHub Actions workflow configuration for scheduled execution and automated commits

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +60 to +61
:ourairports_airport_id => row['airport_ref'].to_i,
:our_airports_id => row['id'].to_i,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these were strings originally, making ints to be consistent

},
:ident => row['ident'],
:municipality => row['municipality'],
:icao_code => row['icao_code'] || row['local_code'] || row['ident'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is right


{
:region => region_name,
:faa_lid => row['local_code'] || row['ident'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks right from what i can tell

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/update-ourairports.yml:
- Line 37: The glob pattern under the workflow's asset add step is wrong: change
the "add: \"*.*json\"" entry to match the generated files (e.g., use "add:
\"json/*.json\"" or "add: \"json/**/*.json\"" so json/airports.json and
json/airport-frequencies.json are included); update the add pattern in the same
workflow step where "add: \"*.*json\"" appears.
🧹 Nitpick comments (6)
scripts/ourairports (4)

19-23: Add error handling for HTTP requests.

Net::HTTP.get doesn't handle redirects or raise on HTTP errors. If the remote server is unavailable or returns an error status, the script will silently produce invalid output.

♻️ Suggested improvement with error handling
 def download_csv(url)
   uri = URI(url)
-  response = Net::HTTP.get(uri)
-  response
+  response = Net::HTTP.get_response(uri)
+  case response
+  when Net::HTTPSuccess
+    response.body
+  when Net::HTTPRedirection
+    download_csv(response['location'])
+  else
+    raise "Failed to download #{url}: #{response.code} #{response.message}"
+  end
 end

37-37: Handle nil values in location string.

If municipality is nil or empty, the location string will produce results like , Region, Country. Consider filtering out nil/empty values.

♻️ Suggested fix
-      :location => "#{row['municipality']}, #{region_name}, #{country_name}",
+      :location => [row['municipality'], region_name, country_name].compact.reject(&:empty?).join(', '),

49-51: Redundant .to_h calls.

Hash literals are already hashes; calling .to_h on them is unnecessary.

♻️ Suggested fix
-    }.to_h
+    }
   end
-  { :airports => airports }.to_h
+  { :airports => airports }
 end

54-66: Consider converting frequency_mhz to a numeric type.

Other numeric fields like ourairports_airport_id and our_airports_id are converted with .to_i, but frequency_mhz remains a string. For consistency and easier downstream use, consider converting it to a float.

♻️ Suggested fix
-      :frequency_mhz => row['frequency_mhz'],
+      :frequency_mhz => row['frequency_mhz'].to_f,
.github/workflows/update-ourairports.yml (2)

19-21: Job name test is misleading.

The job performs a sync/update operation, not testing. Consider renaming to sync or update-airports for clarity.

♻️ Suggested fix
 jobs:
-  test:
+  sync:
     runs-on: ubuntu-latest

24-29: Consider pinning the Ruby version.

ruby/setup-ruby@v1 without a ruby-version input uses the default, which could change over time and cause unexpected behavior.

♻️ Suggested improvement
       - name: Set up Ruby
         uses: ruby/setup-ruby@v1
+        with:
+          ruby-version: '3.2'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants