Skip to content

Commit f94ec4e

Browse files
committed
feat: Enhance exportAndPushJSONToGitHub.sh with intelligent incremental export and documentation updates
- Updated the exportAndPushJSONToGitHub.sh script to implement intelligent incremental export, processing countries one by one and pushing changes immediately. - Added automatic detection of missing or outdated countries, cleanup of obsolete countries from GitHub, and schema validation for JSON files. - Enhanced README generation with an alphabetical list of countries and improved documentation for usage and environment variables. - Introduced new environment variables: MAX_AGE_DAYS and COUNTRIES_PER_BATCH for better control over the export process. - Added unit tests to ensure functionality and maintainability of the script.
1 parent 1f8c59b commit f94ec4e

File tree

5 files changed

+738
-175
lines changed

5 files changed

+738
-175
lines changed

bin/README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ ls -lh ./output/json/countries/ | head -10
348348

349349
**Location:** `bin/dwh/exportAndPushJSONToGitHub.sh`
350350

351-
**Purpose:** Exports JSON files and automatically deploys them to GitHub Pages.
351+
**Purpose:** Exports JSON files and automatically deploys them to GitHub Pages using intelligent incremental mode.
352352

353353
**Usage:**
354354

@@ -358,26 +358,38 @@ ls -lh ./output/json/countries/ | head -10
358358

359359
**Features:**
360360

361-
- Exports datamarts to JSON (calls `exportDatamartsToJSON.sh`)
362-
- Validates all JSON files
363-
- Commits and pushes to Git repository
364-
- Deploys to GitHub Pages automatically
361+
- **Intelligent incremental export**: Exports countries one by one and pushes immediately
362+
- **Automatic detection**: Identifies missing, outdated (default: 30 days), or not exported countries
363+
- **Cleanup**: Removes countries from GitHub that no longer exist in local database
364+
- **Documentation**: Auto-generates README.md with alphabetical list of countries
365+
- **Resilient**: Continues processing even if one country fails
366+
- **Progress tracking**: Shows which countries are being processed
367+
- **Schema validation**: Validates each JSON file before pushing
365368

366369
**Prerequisites:**
367370

368371
- Datamarts must be populated
369-
- Git repository configured
372+
- Git repository configured (`OSM-Notes-Data` cloned to `~/OSM-Notes-Data` or `~/github/OSM-Notes-Data`)
370373
- GitHub Pages enabled
371374
- Git credentials configured
372375

376+
**Environment variables:**
377+
378+
- `MAX_AGE_DAYS`: Maximum age in days before regeneration (default: 30, matches monthly cron)
379+
- `COUNTRIES_PER_BATCH`: Number of countries to process before break (default: 10)
380+
- `DBNAME_DWH`: Database name (default: from etc/properties.sh)
381+
373382
**Example:**
374383

375384
```bash
376-
# Export and deploy to GitHub Pages
385+
# Default: monthly refresh (30 days)
377386
./bin/dwh/exportAndPushJSONToGitHub.sh
387+
388+
# Custom age threshold for testing
389+
MAX_AGE_DAYS=7 ./bin/dwh/exportAndPushJSONToGitHub.sh
378390
```
379391

380-
**Note:** This script is typically scheduled to run after datamart updates.
392+
**Note:** This script is typically scheduled to run monthly via cron after datamart updates.
381393

382394
## Workflow
383395

bin/dwh/ENTRY_POINTS.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,30 @@ These are the **only scripts** that should be executed directly:
129129
7. **`bin/dwh/exportAndPushJSONToGitHub.sh`** - Export and push to GitHub Pages
130130
- **Usage**: `./bin/dwh/exportAndPushJSONToGitHub.sh`
131131
- **Purpose**: Exports JSON files and automatically deploys them to GitHub Pages for OSM-Notes-Viewer (sister project)
132-
- **When**: After datamarts are updated (typically scheduled)
132+
- **When**: After datamarts are updated (typically scheduled monthly via cron)
133133
- **Prerequisites**:
134134
- Datamarts must be populated
135-
- Git repository configured
135+
- Git repository configured (`OSM-Notes-Data` cloned)
136136
- GitHub Pages enabled
137+
- Git credentials configured
137138
- **Consumer**: OSM-Notes-Viewer (sister project) reads these JSON files
139+
- **Features**:
140+
- Intelligent incremental export: exports countries one by one and pushes immediately
141+
- Automatic detection of missing or outdated countries (default: 30 days)
142+
- Removes obsolete countries from GitHub that no longer exist locally
143+
- Generates README.md with alphabetical list of countries
144+
- Resilient: continues processing even if one country fails
145+
- **Environment variables**:
146+
- `MAX_AGE_DAYS`: Maximum age in days before regeneration (default: 30)
147+
- `COUNTRIES_PER_BATCH`: Number of countries before break (default: 10)
148+
- `DBNAME_DWH`: Database name (default: from etc/properties.sh)
138149
- **Example**:
139150
```bash
151+
# Default: monthly refresh (30 days)
140152
./bin/dwh/exportAndPushJSONToGitHub.sh
153+
154+
# Custom age threshold
155+
MAX_AGE_DAYS=7 ./bin/dwh/exportAndPushJSONToGitHub.sh
141156
```
142157

143158
### Maintenance Scripts

0 commit comments

Comments
 (0)