Skip to content

[WHATIF] Remove active_analytics and simplify AccessRequest STI#328

Closed
yshmarov wants to merge 4 commits into
mainfrom
cleanup-remove-analytics-and-simplify-access-requests
Closed

[WHATIF] Remove active_analytics and simplify AccessRequest STI#328
yshmarov wants to merge 4 commits into
mainfrom
cleanup-remove-analytics-and-simplify-access-requests

Conversation

@yshmarov
Copy link
Copy Markdown
Owner

Summary

  • Remove active_analytics gem and related code
  • Replace STI-based AccessRequest system with simpler, more focused models

Changes

Task 1: Remove Active Analytics

  • Remove active_analytics gem from Gemfile
  • Remove analytics mount from admin routes
  • Remove Analytics concern from ApplicationController
  • Add migration to drop active_analytics tables

Task 2: Simplify AccessRequests

Replace the STI-based AccessRequest system with two distinct models:

Before (Complex STI):

AccessRequest (STI base)
├── AccessRequest::InviteToOrganization
└── AccessRequest::UserRequestForOrganization

After (Simple, focused models):

OrganizationInvitation  - org invites user to join
JoinRequest             - user requests to join org

Benefits:

  • Each model has clear, single responsibility
  • No STI magic to understand
  • Easier to extend independently
  • More explicit naming

Test plan

  • All tests pass (155 runs, 536 assertions, 0 failures)
  • Rubocop passes with no offenses
  • Verify invitation flow works in browser
  • Verify join request flow works in browser

🤖 Generated with Claude Code

yshmarov and others added 4 commits January 23, 2026 10:57
- Remove active_analytics gem from Gemfile
- Remove analytics mount from admin routes
- Remove Analytics concern from ApplicationController
- Delete Analytics concern file
- Add migration to drop active_analytics tables

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… models

Simplify the access request system by replacing the STI-based AccessRequest
model with two distinct, focused models:

- OrganizationInvitation: For when an organization invites a user to join
- JoinRequest: For when a user requests to join an organization

Benefits:
- Each model has clear, single responsibility
- No STI inheritance to understand
- Easier to extend independently
- More explicit naming

Changes:
- Create OrganizationInvitation model with pending/approved/rejected status
- Create JoinRequest model with pending/approved/rejected status
- Update Organization associations to use new models
- Update User associations to use new models
- Update controllers and views to reference new models
- Update all tests and fixtures
- Remove old AccessRequest model and STI subclasses
- Add migrations for new tables and dropping old table

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
End-to-end tests covering:
- Admin sending invitations to new users
- Admin canceling pending invitations
- User accepting/declining invitations
- User requesting to join restricted organizations
- User canceling pending join requests
- Admin approving/rejecting join requests
- User directly joining public organizations
- Join requests tab visibility for restricted organizations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Track the user who approves or rejects organization invitations and join requests by adding a completed_by reference. Improve error handling and validation for join requests and invitations, including checks for membership status and pending state. Add notifications for admins when a join request is created, update translations, and enhance related tests for new behaviors.
@yshmarov yshmarov changed the title Remove active_analytics and simplify AccessRequest STI [WHATIF] Remove active_analytics and simplify AccessRequest STI Jan 24, 2026
@yshmarov
Copy link
Copy Markdown
Owner Author

vibecoded. interesting idea with different approach to invitations. not priority now

@yshmarov yshmarov closed this Jan 24, 2026
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