Skip to content

Add HistoricalOwnership foundation for tracking gem ownership history - #6699

Open
nevinera wants to merge 7 commits into
rubygems:masterfrom
nevinera:nev/6534/historical-ownership-foundation
Open

Add HistoricalOwnership foundation for tracking gem ownership history#6699
nevinera wants to merge 7 commits into
rubygems:masterfrom
nevinera:nev/6534/historical-ownership-foundation

Conversation

@nevinera

@nevinera nevinera commented Jul 16, 2026

Copy link
Copy Markdown

Purpose

Create, maintain, and backfill a HistoricalOwnership model, tracking that user X has ever owned/maintained gem Y.

Approach

  • Create a historical_ownerships table and matching model that represents the fact that a user at some point owned a particular gem.
    • We aren't going to try to backfill these past the current ownerships (though it's technically plausible via the Events if we decide we need to later)
    • "Invitations to own" are tracked in the same ownerships table - we only create a historical-ownership when the invitation is accepted (or if it's created already-accepted).
    • Track the highest level of ownership that user had - as it changes, ratchet that value upward. To that end, specify the ownership ordering in HistoricalOwnership and expose a HistoricalOwnership.roles_below(role) method for clarity. (Those roles actually have numerically increasing ordering - if that's intended and part of the semantic contract, I can drop this and just rely on that ordering)
    • Track when that ownership started and stopped (the latter being nil if it's still current)
    • Needed specific attention to the 'Rubygem#disown` method, which skips the ownership hooks.
  • Add a backfill task, imitating the patterns seen in other such tasks.
    • No lifecycle hooks are relevant here, so if we'd like to do this in batches with batch-import I can easily add that (Right now I'm estimating the task will run for 1-2 hours, and batching can take that down to a few minutes safely)

It's worth noting that, while the PRs should be considered and reviewed together, this PR needs to land (and its backfill finish) before the other two are merge-safe.

Decisions

  • Don't try to backfill already-deleted ownership records
  • Invitations don't count as ownership until they are accepted
  • Track the start/end of the owning period (we won't be using it yet, but it opens up a lot of flexibility for use of the data later. downloads-during-tenure, that sort of thing).
  • Track the highest-held role during that period
  • I couldn't find any sign of callback objects or a service layer, so I fattened the Ownership model a bit more - I'm actually more comfortable keeping that extracted a bit, but style-coherency is valuable :-)

Still pending are the updates to the user profile and gems#show/index to reflect the historical stats rather than the current ones, and expose historical owners and historically owned gems as appropriate. I don't think "alumni" is a term of art for this concept/context - I'd propose "Prior Owner Of", and "Prior Owners", but I have reservations about displaying an actual second list on the same page (mostly about behavioral confusion, since we don't appear to have implemented pagination here on the existing lists)

(Slice 1 of ~3 for #6534)

@nevinera
nevinera force-pushed the nev/6534/historical-ownership-foundation branch from c19e19b to d810c95 Compare July 16, 2026 20:38
@nevinera

Copy link
Copy Markdown
Author

(see draft PRs at nevinera#1 and nevinera#2 for usage intent and screenshots)

@jenshenny
jenshenny self-requested a review July 27, 2026 21:52
@colby-swandale
colby-swandale self-requested a review August 7, 2026 02:04
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