Repository navigation
Name history - #340
Open
vangberg wants to merge 43 commits into
Open
Name history#340vangberg wants to merge 43 commits into
vangberg wants to merge 43 commits into
Conversation
This reverts commit 53e736a.
Extend the public history to cover publication roles, name relationships, the genome, the nomenclatural type and external identifiers. Group the polymorphic type's ID and type so each side renders with its own class. Resolve foreign keys through Name's non-polymorphic belongs_to reflections rather than hard-coded attribute lists, and use the generic history_record_reference for publications too.
Pair each polymorphic belongs_to's type and ID columns using its reflection rather than naming nomenclatural_type, and resolve the recorded type to any model class instead of a fixed allowlist.
Serve the history as a nested singular resource at the same URL, and move its helpers and tests alongside it, leaving NamesHelper for displaying names.
Nothing writes type_material and type_accession any more.
Drop tests that only exercise Rails behaviour (no-op saves, transaction rollback, dependent deletes, default scopes, simple delegation), edge cases (empty or Unicode diff input, timestamp-only changes, deleted or unknown polymorphic types, untracked placement creation), and helper and controller tests that repeat what the model tests already cover.
Show linking and unlinking a publication or placement only as a change of 'linked', without the attributes it was added or changed with. Handle the nomenclatural type explicitly instead of discovering polymorphic associations by reflection, both when grouping its type and ID and when rendering them.
Restore finding polymorphic associations by reflection in history_attribute_values, consistent with how other associations are matched there.
vangberg
marked this pull request as ready for review
October 29, 2026 19:05
Contributor
Author
|
My biggest issue is Quick sketch of what that would look like: https://github.com/seq-code/registry/compare/name-history...name-history-version-owner?expand=1 Hmm. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #44
Ready for review. This ended up being more code than I anticipated, and I think I could keep changing things here and there, so I think it is better to move on and start reviewing. Don't hold back, I am very open to changing overall direction if we can make it simpler :)
Overview:
Versionedconcern tracks model changes asVersionrecords.versioned_togethergroups attributes, so if one attribute changes, we record the current state of the whole group. Useful for e.g. etymology.PublicHistorytakes aNamerecord and fetches all relevantVersionrecords for itself + associations and turns it into a format that is easy for the views to consume.Currentmodel is anActiveSupport::CurrentAttributes, which allows us to set per-request globals, i.e. current user.Unlinkableapproach for theSoftDeletableconcern with adefault_scope. The#linkedscope ended up creeping up in so many places that I think the soft-deletion approach is saner.Tracking versions
This PR adds a
Versionedconcern. When included in a model,Versionrecords are automatically created on create/update/delete, and aversionsassociation is added to the model.This is what an update to
Namewhich changesproposed_in_idlooks like:Tracking changes to etymology
A change to one etymology attribute should snapshot the current value of all etymology attributes ( +
namewhich is used byfull_etymology). This is done withversioned_together, which lets you specify which attributes should be tracked as a single attribute.Public history
When rendering the history, we need to:
This is all orchestrated by
Name::PublicHistory.UI
Value flow
Single attribute
Name#syllabication
↓ Version#changeset
↓ PublicHistory#changes_for(version)
Grouped etymology
Name#etymology_xx_description
↓ Version#changeset — includes unchanged companions
↓ PublicHistory#changes_for(version) — groups before/after snapshots