feat: add database-backed invitation logging and resilient bulk invitations#2546
Open
mroderick wants to merge 6 commits intocodebar:masterfrom
Open
feat: add database-backed invitation logging and resilient bulk invitations#2546mroderick wants to merge 6 commits intocodebar:masterfrom
mroderick wants to merge 6 commits intocodebar:masterfrom
Conversation
- Use find_or_create_by instead of create to handle duplicate invitations - Add exception handling to catch database errors and continue processing - Log errors at ERROR level with member_id and context IDs (workshop/event/meeting) - Add tests for exception handling and bulk resilience - Update existing tests to use find_or_create_by This fixes issue codebar#2542 where workshop invitations would fail silently if any individual member's invitation creation raised an exception, causing the entire bulk invitation process to abort and leaving remaining members without invitations.
Collaborator
Author
|
Putting this back to draft, I have more improvements up my sleeve |
- Create invitation_logs and invitation_log_entries tables - Add InvitationLog model with enums, associations, expiration callback - Add InvitationLogEntry model with status tracking - Add fabricators for test data - Add model specs Co-Authored-By: opencode <noreply@opencode.ai>
- Service for logging invitation batch operations - Tracks success/failure/skip counts per batch - Provides convenience methods for starting/finishing/failing batches Co-Authored-By: opencode <noreply@opencode.ai>
- Add invitation_logs association to Workshop model - Integrate InvitationLogger into workshop email sending - Pass current_user.id for audit trail - Handle WorkshopPresenter via workshop.model in scope Co-Authored-By: opencode <noreply@opencode.ai>
- Add WorkshopInvitationLogsController with index/show actions - Add InvitationLogPolicy for authorization - Add views for listing and detail of invitation logs - Add route nesting under admin/workshops - Add seed data for invitation logs - Add controller and policy specs Co-Authored-By: opencode <noreply@opencode.ai>
- Add CleanupExpiredInvitationLogsJob for 180-day retention - Add rake task invitation_logs:cleanup - Add job specs Co-Authored-By: opencode <noreply@opencode.ai>
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.
Summary
Fixes #2542 - Adds database-backed logging for workshop invitations and makes bulk invitation creation resilient to individual failures.
This enables administrators to:
Additionally, bulk invitation creation now continues gracefully if any individual member fails, rather than crashing the entire batch.
Problem
When sending workshop invitations in bulk, two problems existed:
No logging - There was no way to track which invitations were sent, who initiated them, or which ones failed. Debugging invitation issues required manual database queries.
Fragile batch processing - If any single member failed during invitation creation (e.g., due to a database constraint violation), the entire process would crash. The remaining members would never receive invitations.
For example, if sending invites to 700 members and the 300th member's invitation creation failed, the remaining 400 members would never be invited.
Solution
Invitation Logging
Added a polymorphic logging system with two models:
The
InvitationLoggerservice integrates withInvitationManagerto log every workshop/virtual workshop email send. Logs are viewable from the admin workshop page.Resilient Bulk Invitations
find_or_create_byto handle duplicate invitations safelybegin/rescueto catchStandardErrorChanges
5db155269312a829c3bbc8d9234fca52189a0ba4Total: 42 tests passing across all commits
How to Verify
Set up an admin user
View invitation logs
bundle exec rails server/admin/workshops/:idSeed data
This creates sample invitation logs across past workshops.
Cleanup expired logs
Run tests
All 42 tests pass.