Skip to content

OpenConceptLab/ocl_issues#2947 | Data migration: TBv2 My Pins become follows - #953

Merged
paynejd merged 1 commit into
masterfrom
ocl_issues-2947-pins-to-follows
Oct 22, 2026
Merged

paynejd merged 1 commit into
masterfrom
ocl_issues-2947-pins-to-follows

Conversation

@paynejd

@paynejd paynejd commented Oct 22, 2026

Copy link
Copy Markdown
Member

TBv3 keeps pins as overview highlights and lists follows as personal shortcuts. TBv2's My Pins list (GET /users/<me>/pins/?includeCreatorPins=true) showed a person's own pins plus the org pins they created, so this one-time data migration turns each person's list into follows.

What changed

  • New data migration core/pins/migrations/0005_pins_to_follows.py. For every pin it follows the pinned org, source or collection for the person whose My Pins list showed it: the pin's user for a user pin, the pin's creator for an org pin.
  • Skips a pin when the resource is gone or deleted (is_active=False, which the follow API refuses too), or when the person can no longer view it. Viewing follows CanViewConceptDictionary: public, staff, the repo's owner, or a member of the org that owns it. A repo version counts as public only while its HEAD is. Org pins also need the person to still see the pinning org, as Pin.get_visible_to required for that list.
  • Follows are inserted with bulk_create(..., ignore_conflicts=True), not UserProfile.follow(), so no Followed events are recorded and an existing follow stays as it is. Pins are untouched. The reverse is a no-op, since by then people may have changed their follows.
  • Dependencies: pins.0004, users.0037, orgs.0022, sources.0046, collections.0071, contenttypes.0002. Historical models only.

How I verified it

  • PinsToFollowsMigrationTest runs the migration function with historical models (MigrationLoader(...).project_state(...)) on a dataset covering: user pins, org pins (follower = creator), an existing follow (kept, no duplicate), a deleted source, an inactive collection, private repos and a private org the follower lost access to (skipped) or can still see (followed), a staff creator, a public version of a private HEAD, an org pin whose private org the creator can't see, and a second run (adds nothing). It checks pins and the Event count are unchanged, and that each person's follows equal their includeCreatorPins=true list less the deleted resources. 8 follows (7 new) on that dataset.
  • Mutation check: dropping the creator rule, the pinning-org check, the HEAD check, the is_active filter or the owner check each fails the test.
  • python manage.py test core.pins core.users --keepdb (107 tests, OK); pylint -j2 core 10.00; migrate, migrate pins 0004 and migrate pins run cleanly; makemigrations --dry-run shows only the known local MapProject.encoder_model drift, not included.

The web side (oclweb3) is a separate PR.

Part of OpenConceptLab/ocl_issues#2947

🤖 Generated with Claude Code

https://claude.ai/code/session_01TjM9dGow2KV1Gwr2dWQdph

…y Pins become follows

For every pin, follow the pinned org or repo for the person whose TBv2 My Pins list showed it
(a user pin's user, an org pin's creator), unless it's gone or they can no longer view it.
Follows are inserted directly, so no Followed events are recorded. Pins are untouched, and the
reverse migration does nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TjM9dGow2KV1Gwr2dWQdph

@paynejd paynejd left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex review, pass 1 (codex-cli 0.163.0, commit 833ac23)

Verdict: clean, no findings.

findings.json
{
  "reviewer": "codex-cli 0.163.0",
  "perspective": "defects",
  "mode": "full",
  "commit": "833ac23d",
  "verdict": "clean",
  "prior": [],
  "findings": []
}

@paynejd

paynejd commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

Simplification review (claude subagent, commit 833ac23)

Verdict: clean, nothing to cut. No commits since Codex pass 1, so no follow-up Codex check is needed.

simplify.json
{
  "reviewer": "claude subagent",
  "perspective": "simplify",
  "mode": "full",
  "commit": "833ac23d",
  "verdict": "clean",
  "prior": [],
  "findings": []
}

@paynejd
paynejd merged commit 0c4bae2 into master Oct 22, 2026
3 checks passed
@paynejd
paynejd deleted the ocl_issues-2947-pins-to-follows branch October 22, 2026 18:41
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