Skip to content

feat(catalog): real catalog display names#477

Draft
mrosseel wants to merge 1 commit into
brickbots:mainfrom
mrosseel:feat/catalog-display-names
Draft

feat(catalog): real catalog display names#477
mrosseel wants to merge 1 commit into
brickbots:mainfrom
mrosseel:feat/catalog-display-names

Conversation

@mrosseel

Copy link
Copy Markdown
Collaborator

What

Make a readable catalog name a first-class data field so the UI can show e.g. Collinder 24 sourced from data instead of a hardcoded code→name map. Today the catalogs table only has catalog_code, max_sequence, and a long free-text desc, so the UI falls back to codes (Col 24, H 244).

Changes

  • Schema (db/objects_db.py): add a name TEXT column to the catalogs CREATE TABLE and to ObjectsDatabase.insert_catalog().
  • Write path: catalog_imports/catalog_import_utils.insert_catalog() gains a display_name param. All ~21 loader call sites now pass a readable name (NGC, IC, Messier, Caldwell, Herschel, Collinder, TAAS 200, SAC Asterisms/Doubles/Red Stars, Bright Stars, Extragalactic Globular Clusters, RASC Double Stars, Barnard, Sharpless, Abell, Arp, TLK Variable Stars, Washington Double Star, Harris, Lynga).
  • Read path: expose name on the in-memory Catalog / CatalogBase, populated from get_catalogs_dict(). Falls back to None (UI uses the code) for virtual catalogs (planets, comets) and legacy rows.
  • Migration: the shipped astro_data/pifinder_objects.db is a pre-built binary without this column. A one-time, idempotent migration runs on startup (ObjectsDatabase.__init__): if name is missing it does ALTER TABLE catalogs ADD COLUMN name TEXT then UPDATEs each row by catalog_code from a canonical map, so existing installs get names without a full re-import. The migration is race-safe (catches duplicate-column on concurrent startup) and a no-op once applied.
  • Cache: bump CACHE_VERSION to 2 since the cached Catalog / catalogs_info shape changed.

The shipped binary DB is intentionally not modified in this PR — names are applied at runtime by the migration (verified: all 21 catalogs backfill correctly).

Consumer note

Step 5 of the original task was a one-line change in object_details._other_catalog_descriptions to build the section label from the catalog name (falling back to the code). That method is part of an as-yet-unmerged observing-list feature and does not exist on brickbots/main, so it is not included here. Once it lands, the change is simply: look up the catalog name via catalogs.get_catalog_by_code(code).name and render f"{name} {sequence}", falling back to the code when name is None.

Testing

  • ruff check + ruff format --check: clean.
  • pytest tests/test_catalog_cache.py tests/test_catalog_data.py: 11 passed.
  • Verified the startup migration backfills all 21 catalog names on the real shipped DB.

🤖 Generated with Claude Code

Make a readable catalog name a first-class data field so the UI can show
e.g. "Collinder 24" sourced from data instead of a hardcoded code->name map.

- Schema: add a `name TEXT` column to the catalogs table and to
  ObjectsDatabase.insert_catalog().
- Write path: catalog_import_utils.insert_catalog() gains a display_name
  param; all ~21 loader call sites now pass a readable name (Collinder,
  Herschel, Lynga, Caldwell, Barnard, Sharpless, Abell, Arp, Harris,
  SAC Asterisms/Doubles/Red Stars, Bright Stars, etc.).
- Read path: expose `name` on the in-memory Catalog / CatalogBase, populated
  from get_catalogs_dict(); falls back to None (UI uses the code) for virtual
  or legacy catalogs.
- Migration: pre-built databases shipped without the column get it backfilled
  on startup (ALTER TABLE + UPDATE by catalog_code), idempotent and race-safe.
- Bump CACHE_VERSION to 2 since the cached Catalog/catalogs_info shape changed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant