Skip to content

feat: ETL steps for star systems and orbits#212

Merged
GitAddRemote merged 4 commits into
mainfrom
feature/ISSUE-191
May 24, 2026
Merged

feat: ETL steps for star systems and orbits#212
GitAddRemote merged 4 commits into
mainfrom
feature/ISSUE-191

Conversation

@GitAddRemote
Copy link
Copy Markdown
Owner

Summary

  • StarSystemsSyncStep — fetches /star_systems, upserts station_star_system on uex_id; maps faction_uex_id, jurisdiction_uex_id, boolean flags, wiki, and timestamps; warns and skips records missing a name
  • OrbitsSyncStep — fetches /orbits, validates each orbit's id_star_system against the current station_star_system table before inserting; emits a top-level warning if the table is empty (upstream step likely failed); warns and skips orbits with null or unknown star system FK; also fetches /orbit_distances, validates both orbit FKs, and upserts station_orbit_distance — warns and skips on any unknown FK
  • Both steps registered in CatalogEtlModule and CatalogEtlService at tier-2 (star systems) and tier-3 (orbits) per dependency order
  • CatalogEtlService spec updated with mock providers for the two new steps

Test plan

  • 15 new unit tests across 2 spec files — all 41 catalog-etl tests passing locally
  • TypeScript typecheck passes (backend + frontend)
  • Lint/Prettier clean (enforced by pre-commit hook)
  • After ETL run: SELECT count(*) FROM station_star_system matches UEX count
  • After ETL run: all station_orbit rows have a non-null star_system_uex_id
  • Orbit with unknown id_star_system appears in station_etl_warning and is absent from station_orbit

Closes #191

- Add StarSystemsSyncStep: upserts station_star_system on uex_id; maps
  faction_uex_id, jurisdiction_uex_id, wiki, boolean flags, and timestamps;
  warns and skips records missing a name

- Add OrbitsSyncStep: upserts station_orbit on uex_id after validating
  id_star_system against the set of known star systems in DB; emits a
  top-level warning when station_star_system is empty (star-systems step
  likely failed); warns and skips orbits with null or unknown star system

  Also syncs station_orbit_distance from /orbit_distances; skips and warns
  when either orbit FK is unknown

- Register both steps in CatalogEtlModule and CatalogEtlService (star
  systems at tier-2, orbits at tier-3 per dependency order)

- Add mock providers for StarSystemsSyncStep and OrbitsSyncStep in the
  CatalogEtlService spec

- 15 new unit tests; all 41 catalog-etl tests passing; typecheck clean

Closes #191
Copilot AI review requested due to automatic review settings May 23, 2026 22:41
Copy link
Copy Markdown
Contributor

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

… ETL

- Move starSystemsSyncStep before factionsSyncStep so faction→star system
  junction reconciliation finds populated rows on the first run
- Guard faction_uex_id and jurisdiction_uex_id writes in StarSystemsSyncStep
  and syncOrbits() — unknown FKs are stored as null with a warning instead
  of raising a DB FK violation
- Guard star_system_origin/dest_uex_id writes in syncOrbitDistances() —
  unknown star system FKs are stored as null with a warning instead of
  raising a DB FK violation
- Add unit tests covering all three failure modes (8 new tests across 2
  spec files; 32 total passing)
Move reconcileStarSystems() from FactionsSyncStep into StarSystemsSyncStep
so it runs after both factions and star systems are populated. Step order
is now factions → jurisdictions → starSystems → companies → orbits:

- StarSystemsSyncStep re-fetches /factions at the end of execute() and
  reconciles station_faction_star_system in full (delete + re-insert),
  replicating the prior FactionsSyncStep logic but in the correct position
- FactionsSyncStep no longer touches station_faction_star_system
- Junction reconciliation tests moved from factions-sync.step.spec.ts to
  star-systems-sync.step.spec.ts; 44 unit tests passing
Copilot AI review requested due to automatic review settings May 24, 2026 04:12
Copy link
Copy Markdown
Contributor

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

… factions-sync

Load station_faction rows at the start of reconcileStarSystemJunctions() and
skip any faction from /factions that was not persisted — warns and skips the
DELETE+INSERT block entirely to avoid a FK violation on station_faction_star_system.
Adds test covering a named faction absent from the DB.
@GitAddRemote GitAddRemote merged commit 9e84a27 into main May 24, 2026
9 checks passed
@GitAddRemote GitAddRemote deleted the feature/ISSUE-191 branch May 24, 2026 05:26
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.

ETL: sync star systems and orbits into station_* tables

2 participants