Skip to content

Format data cleanup: dedup typos, backfill orphans, fix mis-typed LP/Singles (#370 Phase 2a) #376

Description

@holden

Context

Splitting the data half of #370 Phase 2 out from the UI half. Has standalone value (cleaner edit forms, accurate exports, better search) and unblocks future sub-facet UI work without forcing it.

Live audit of record_formats.name per record_type for user 1 (20,380 records):

45s (14,710 records):
  13,221  Singles: 7-inch
   1,147  Promotional Singles
     273  EPs: 7-inch
      44  Gold Standard Singles with '447' prefix
      15  Picture Disc Singles
       7  EPs: 7-inch 45 rpm           ← likely typo dup of EPs: 7-inch
       2  Gold Standard Singles with 'GB' prefix
       1  Plastic Soundsheets/Flexi-Discs ← misclassified (belongs under Picture Sleeves)

LPs (4,536 records):
   4,320  LPs: 10/12-inch
     135  Singles: 10/12-inch          ← these are 12\" Singles; arguably wrong type
      64  Singles: 12-inch             ← same
       6  EPs: 10-inch
       3  Promotional 12-inch Singles
       3  EPs: 12-inch
       2  Singles: 12-inch 33/45
       2  Promotional Singles: 12-inch
       1  Promotional LPs              ← redundant; merge into LPs: 10/12-inch?

Picture Sleeves (1,007 records):
   1,002  Picture Sleeves
       5  Gold Standard Picture Sleeves

78s (123 records):
     121  Singles: 78 rpm
       1  78 rpm Album                 ← typo dup
       1  Albums: 78 rpm               ← typo dup

ORPHANS (record_type_id = NULL):
       1  EPs: 7-inch 33/45            → assign to 45s
       1  LPs 10/12-inch               → typo dup of \"LPs: 10/12-inch\", reassign records and drop
       1  Singles: 14-inch             → assign to LPs (closest current bucket)
       1  Picture Sleeve               → typo dup of \"Picture Sleeves\", reassign records and drop

Scope

Idempotent Rake task: bin/rails db:cleanup:record_formats (or a one-shot data migration). Must:

A. Backfill 4 orphan formats with record_type_id

Format Action
EPs: 7-inch 33/45 record_type_id = 45s id
LPs 10/12-inch (handled in B — merge into canonical)
Singles: 14-inch record_type_id = LPs id (least bad fit)
Picture Sleeve (handled in B — merge into canonical)

B. Merge typo / casing dups

For each pair, repoint records.record_format_id to the canonical row, then delete the duplicate row from record_formats:

Duplicate Canonical
LPs 10/12-inch (no colon) LPs: 10/12-inch
Picture Sleeve (singular) Picture Sleeves
78 rpm Album Albums: 78 rpm (or vice versa — pick one)
EPs: 7-inch 45 rpm EPs: 7-inch (likely intent — confirm)

C. Reclassify mis-typed LP/Singles records

The 199 records currently filed under LPs but tagged Singles: 10/12-inch / Singles: 12-inch / Singles: 12-inch 33/45 are 12" Singles — physically distinct from LPs. Two options:

  1. Add a new record_type 'Singles: 12-inch' and reassign these formats to it
  2. Leave them under LPs (status quo, but flag in the cleanup task report)

Recommendation: option 1, with the migration creating the new type. Need product confirmation before shipping.

D. Drop / merge 1-record stragglers

  • Plastic Soundsheets/Flexi-Discs (1 record under 45s) → reassign record to Picture Sleeves and drop the format row, OR keep as-is if intentional
  • Promotional LPs (1 record under LPs) → merge into LPs: 10/12-inch if user intent was the same, or keep
  • Singles: 14-inch (1 record orphan, after backfill) → keep but flag

These are subjective — the cleanup task should report them and ask for sign-off, not auto-merge.

Implementation notes

  • Wrap repointing + row-delete in a transaction per merge to keep referential integrity safe
  • Print before/after counts for each action
  • Add a --dry-run flag (default) so the task can be reviewed before mutating
  • After the task runs, expected record_formats row count drops from ~57 → ~12 (counting only formats with at least one record assigned)

Out of scope

  • Sub-format UI (tracked in companion issue, gated on this)
  • Schema changes beyond optionally adding the "12" Single" record_type row
  • Long-term taxonomy redesign (e.g. an orthogonal "intent" column for Promo / EP / Single)

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions