Skip to content

Name history - #340

Draft
vangberg wants to merge 12 commits into
mainfrom
name-history
Draft

vangberg wants to merge 12 commits into
mainfrom
name-history

Conversation

@vangberg

@vangberg vangberg commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

[WIP]

Tracking versions

This PR adds a Versioned concern. When included in a model, Version records are automatically created on create/update/delete, and a versions association is added to the model.

This is what an update to Name which changes proposed_in_id looks like:

>> p name.versions.last
#<Version:0x000000015401f158
 id: 20,
 record_type: "Name",
 record_id: 55876,
 operation: "update",
 changeset: {"proposed_in_id"=>[4482, 2667]},
 created_at: Fri, 02 Oct 2026 12:29:52.288092000 UTC +00:00>
irb(main):018> 

Tracking changes to etymology

A change to one etymology attribute should snapshot the current value of all etymology attributes ( + name which is used by full_etymology). This is done with versioned_together, which lets you specify which attributes should be tracked as a single attribute.

Public history

When rendering the history, we need to:

  1. Only show history for some attributes -- other attributes are internal.
  2. Group etymology changes together.
  3. At a later point, fetch the history for associations.

This is all orchestrated by Name::PublicHistory.

UI

CleanShot-2026-10-02-15-36-10 CleanShot-2026-10-02-15-35-45

Todo

  • Track changes to associations (placements, publications). Follow-up PR on its way.
  • Thorough review of which attributes need to be whitelisted.
  • Specific rendering rules for various attributes (see history_values)
  • Review if we actually need to operation attribute.
  • Should create/destroy dump all attributes in the version? I think so.

Value flow

Single attribute

Name#syllabication

nil → 'co.li'

↓ Version#changeset

{
  'syllabication' => [nil, 'co.li']
}

↓ PublicHistory#changes_for(version)

{
  'syllabication' => [nil, 'co.li']
}

Grouped etymology

Name#etymology_xx_description

'of the colon' → 'from the colon'

↓ Version#changeset — includes unchanged companions

{
  'name' => ['E. coli', 'E. coli'],
  'etymology_xx_lang' => ['N.L.', 'N.L.'],
  'etymology_xx_description' => ['of the colon', 'from the colon']
}

↓ PublicHistory#changes_for(version) — groups before/after snapshots

{
  'etymology' => [
    {
      'name' => 'E. coli',
      'etymology_xx_lang' => 'N.L.',
      'etymology_xx_description' => 'of the colon'
    },
    {
      'name' => 'E. coli',
      'etymology_xx_lang' => 'N.L.',
      'etymology_xx_description' => 'from the colon'
    }
  ]
}

@vangberg vangberg self-assigned this Oct 2, 2026
@vangberg
vangberg added this pull request to stack #342 October 8, 2026 07:18
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