Follow-up updates for bug fix

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2025-10-27 14:28:33 -05:00
parent 6cf6dfc639
commit 03baf3a031
4 changed files with 62 additions and 338 deletions

View File

@ -1,299 +0,0 @@
# Discord Bot v2.0 - Pre-Launch Roadmap
**Last Updated:** January 2025
**Target Launch:** TBD
**Current Status:** Core functionality complete including trading system, remaining utility commands needed
## 🎯 Overview
This document outlines the remaining functionality required before the Discord Bot v2.0 can be launched to replace the current bot. All core league management features are complete - this roadmap focuses on utility commands, integrations, and user experience enhancements.
## ✅ Completed Core Features
- **Player Information** (`/player`) - Comprehensive player cards with stats
- **Team Management** (`/team`, `/teams`, `/roster`) - Team information and roster breakdown
- **League Operations** (`/league`, `/standings`, `/schedule`) - League-wide information
- **Transaction Management** (`/mymoves`, `/legal`) - Player transaction tracking
- **Trading System** (`/trade`) - Full interactive trading with validation and dedicated channels
- **Voice Channels** (`/voice-channel`) - Automatic gameplay channel creation with cleanup
- **Custom Commands** (`/custom-command`) - User-created custom text commands
- **Admin Commands** - League administration and management tools
- **Background Services** - Automated cleanup, monitoring, and maintenance
## 🚧 Remaining Pre-Launch Requirements
### 🔧 Critical Fixes Required
#### 1. Custom Command Backend Support **✅ COMPLETED**
- **Status**: Complete and functional
- **Implementation**: Custom commands system fully operational
- **Features**: Users can create/manage custom text commands
- **Files**: `commands/custom_commands/`, `services/custom_command_service.py`
- **Completed**: January 2025
### 🎮 Utility Commands
#### 2. Weather Command **✅ COMPLETED**
- **Command**: `/weather [team_abbrev]`
- **Status**: Complete and fully functional
- **Implementation**: Ballpark weather rolling system for gameplay
- **Features Implemented**:
- Smart team resolution (explicit param → channel name → user owned team)
- Season display (Spring/Summer/Fall based on week)
- Time of day logic (division weeks, games played tracking)
- D20 weather roll with formatted display
- Stadium image and team color styling
- **Completed**: January 2025
#### 3. Charts Display System **✅ COMPLETED**
- **Command**: `/charts <chart-name>`
- **Status**: Complete and fully functional
- **Implementation**: Chart display and management system
- **Features Implemented**:
- Autocomplete chart selection with category display
- Multi-image chart support
- JSON-based chart library (12 charts migrated from legacy bot)
- Admin commands for chart management (add, remove, list, update)
- Category organization (gameplay, defense, reference, stats)
- Proper embed formatting with descriptions
- **Data Storage**: `data/charts.json` with JSON persistence
- **Completed**: January 2025
#### 4. Custom Help System **✅ COMPLETED**
- **Commands**: `/help [topic]`, `/help-create`, `/help-edit`, `/help-delete`, `/help-list`
- **Status**: Complete and ready for deployment (requires database migration)
- **Description**: Comprehensive help system for league documentation, resources, FAQs, and guides
- **Features Implemented**:
- Create/edit/delete help topics (admin + "Help Editor" role)
- Categorized help library (rules, guides, resources, info, faq)
- Autocomplete for topic discovery
- Markdown-formatted content
- View tracking and analytics
- Soft delete with restore capability
- Full audit trail (who created, who modified)
- Interactive modals for creation/editing
- Paginated list views
- Permission-based access control
- **Data Storage**: PostgreSQL table `help_commands` via API
- **Replaces**: Planned `/links` command (more flexible solution)
- **Documentation**: See `commands/help/README.md` and `.claude/DATABASE_MIGRATION_HELP_COMMANDS.md`
- **Completed**: January 2025
### 🖼️ User Profile Management
#### 5. Image Management Commands **✅ COMPLETED**
- **Command**: `/set-image <image_type> <player_name> <image_url>`
- **Status**: Complete and fully functional
- **Description**: Allow users to update player fancy card and headshot images
- **Features Implemented**:
- Single command with fancy-card/headshot choice parameter
- Player name autocomplete (prioritizes user's team)
- Comprehensive URL validation (format + accessibility testing)
- Preview embed with confirmation dialog
- Permission system (users can edit org players, admins can edit anyone)
- Integration with existing player card system
- HTTP HEAD request to test URL accessibility
- Content-type verification (must be image/*)
- **Permissions**:
- Regular users: Can update players in their organization (ML/MiL/IL)
- Administrators: Can update any player's images
- **Database**: Updates `vanity_card` or `headshot` fields in player model
- **Documentation**: See `commands/profile/README.md`
- **Tests**: Comprehensive test coverage (22 tests) in `tests/test_commands_profile_images.py`
- **Completed**: January 2025
### 🎯 Gaming & Entertainment
#### 6. Meme Commands
- **Primary Command**: `/lastsoak`
- **Description**: Classic SBA meme commands for community engagement
- **Features**:
- `/lastsoak` - Display last player to be "soaked" (statistical reference)
- Embed formatting with player info and stats
- Historical tracking of events
- **Data Source**: Database queries for recent player performance
- **Estimated Effort**: 1-2 hours
#### 7. Scouting System
- **Command**: `/scout [options]`
- **Description**: Weighted dice rolling system for scouting mechanics
- **Features**:
- Multiple dice configurations
- Weighted probability systems
- Result interpretation and display
- Historical scouting logs
- **Complexity**: Custom probability algorithms
- **Estimated Effort**: 3-4 hours
#### 8. Trading System **✅ COMPLETED**
- **Command**: `/trade [parameters]`
- **Status**: Complete and fully functional
- **Implementation**: Full interactive trading system with comprehensive features
- **Features Implemented**:
- Trade proposal system with interactive UI
- Multi-party trade support (up to 2 teams)
- Trade validation (roster limits, salary caps, sWAR tracking)
- Trade history and tracking
- Integration with transaction system
- Dedicated trade discussion channels with smart permissions
- Pre-existing transaction awareness for accurate projections
- **Completed**: January 2025
## 📋 Implementation Priority
### Phase 1: Critical Fixes ✅ COMPLETED
1. ✅ **Custom Command Backend** - Fixed and fully operational (January 2025)
### Phase 2: Core Utilities
2. ✅ **Weather Command** - Complete with smart team resolution (January 2025)
3. ✅ **Charts System** - Complete with admin management and 12 charts (January 2025)
4. ✅ **Help System** - Complete with comprehensive help topics and CRUD capabilities (January 2025)
### Phase 3: User Features
5. ✅ **Image Management** - Complete with URL validation and permissions (January 2025)
6. **Meme Commands** - Community engagement
### Phase 4: Advanced Features
7. **Scout Command** - Complex gaming mechanics
8. ✅ **Trade Command** - Complete with comprehensive features (January 2025)
## 🏗️ Architecture Considerations
### Command Organization
```
commands/
├── utilities/
│ ├── weather.py # Weather command
│ ├── charts.py # Charts display system
│ └── links.py # Resource links system
├── profile/
│ └── images.py # Image management commands
├── gaming/
│ ├── memes.py # Meme commands (lastsoak)
│ ├── scout.py # Scouting dice system
│ └── trading.py # Trade management system
```
### Service Layer Requirements
- **WeatherService**: API integration for weather data
- **ResourceService**: Chart and link management
- **ProfileService**: User image management
- **ScoutingService**: Dice mechanics and probability
- ✅ **TradingService**: Complete - complex trade logic and validation implemented (January 2025)
### Database Schema Updates
- ✅ **Custom commands**: Complete and operational (January 2025)
- **Resources**: Chart/link storage tables
- **Player images**: Image URL fields
- ✅ **Trades**: Complete - trade proposal and history tables implemented (January 2025)
## 🧪 Testing Requirements
### Test Coverage Goals
- **Unit Tests**: All new services and commands
- **Integration Tests**: Database interactions, API calls
- **End-to-End Tests**: Complete command workflows
- **Performance Tests**: Database query optimization
### Test Categories by Feature
- **Weather**: API mocking, error handling, rate limiting
- **Charts/Links**: URL validation, admin permissions
- **Images**: URL validation, permission checks
- ✅ **Trading**: Complete - complex multi-user scenarios, validation logic all tested (January 2025)
## 📚 Documentation Updates
### User-Facing Documentation
- Command reference updates
- Feature guides for complex commands (trading, scouting)
- Admin guides for resource management
### Developer Documentation
- Service architecture documentation
- Database schema updates
- API integration guides
## ⚡ Performance Considerations
### Database Optimization
- Index requirements for new tables
- Query optimization for complex operations (trading)
- Cache invalidation strategies
### API Rate Limiting
- Weather API rate limits and caching
- Image URL validation and caching
- Error handling for external services
## 🚀 Launch Checklist
### Pre-Launch Validation
- [ ] All commands functional and tested
- [ ] Database migrations completed
- [ ] API keys and external services configured
- [ ] Error handling and logging verified
- [ ] Performance benchmarks met
### Deployment Requirements
- [ ] Environment variables configured
- [ ] External API credentials secured
- [ ] Database backup procedures tested
- [ ] Rollback plan documented
- [ ] User migration strategy defined
## 📊 Success Metrics
### Functionality Metrics
- **Command Success Rate**: >95% successful command executions
- **Response Time**: <2 seconds average response time
- **Error Rate**: <5% error rate across all commands
### User Engagement
- **Command Usage**: Track usage patterns for new commands
- **User Adoption**: Monitor migration from old bot to new bot
- **Community Feedback**: Collect feedback on new features
## 🔮 Post-Launch Enhancements
### Future Considerations (Not Pre-Launch Blockers)
- Advanced trading features (trade deadline management)
- Enhanced scouting analytics and reporting
- Weather integration with game scheduling
- Mobile-optimized command interfaces
- Advanced user profile customization
---
## 📞 Development Notes
### Current Bot Architecture Strengths
- **Robust Service Layer**: Clean separation of concerns
- **Comprehensive Testing**: 44+ tests with good coverage
- **Modern Discord.py**: Latest slash command implementation
- **Error Handling**: Comprehensive error handling and logging
- **Documentation**: Thorough README files and architectural docs
### Technical Debt Considerations
- ✅ **Custom Commands**: Resolved - backend fully operational (January 2025)
- ✅ **Trading System**: Complete with comprehensive validation (January 2025)
- **Database Performance**: Monitor query performance with new features
- **External Dependencies**: Manage API dependencies and rate limits
- **Cache Management**: Implement caching for expensive operations
### Resource Requirements
- **Development Time**: ~4-6 hours remaining (reduced from 20-25 hours)
- ✅ Custom Commands: Complete (saved 2-3 hours)
- ✅ Trading System: Complete (saved 6-8 hours)
- ✅ Weather Command: Complete (saved 3-4 hours)
- ✅ Charts System: Complete (saved 2-3 hours)
- ✅ Help System: Complete (saved 2-3 hours)
- ✅ Image Management: Complete (saved 2-3 hours)
- Remaining: Memes (1-2h), Scout (3-4h)
- **API Costs**: None required (weather is gameplay dice rolling, not real weather)
- **Database Storage**: Minimal increase for new features
- **Hosting Resources**: Current infrastructure sufficient
---
**Target Timeline: 1 week for complete pre-launch readiness**
**Next Steps: Implement remaining features (meme commands and scouting system)**

View File

@ -305,6 +305,13 @@ Run tests with:
- Immediate database POST and player team updates
- Same interactive UI with "immediate" submission handler
- Supports multiple moves in single transaction
- ✅ **CRITICAL FIX: Scheduled Transaction Database Persistence** (October 2025)
- **Bug**: `/dropadd` transactions were posted to Discord but NEVER saved to database
- **Impact**: Week 19 transactions were completely lost - posted to Discord but freeze task found 0 transactions
- **Root Cause**: `submit_transaction()` only created Transaction objects in memory without database POST
- **Fix**: Added `create_transaction_batch()` call with `frozen=True` flag in scheduled submission handler
- **Result**: Transactions now properly persist to database for weekly freeze processing
- **Files Changed**: `views/transaction_embed.py:243-248`, `tests/test_views_transaction_embed.py:255-285`
### Previous Enhancements
- ✅ **Multi-Team Trade System**: Complete `/trade` command group for 2+ team trades

View File

@ -250,16 +250,21 @@ class TestSubmitConfirmationModal:
mock_transaction = MagicMock()
mock_transaction.moveid = 'Season-012-Week-11-123456789'
mock_transaction.week = 11
mock_transaction.frozen = False # Will be set to True
with patch('services.league_service.LeagueService') as mock_league_service_class:
mock_league_service = MagicMock()
mock_league_service_class.return_value = mock_league_service
with patch('services.league_service.league_service') as mock_league_service:
mock_current_state = MagicMock()
mock_current_state.week = 10
mock_league_service.get_current_state = AsyncMock(return_value=mock_current_state)
modal.builder.submit_transaction.return_value = [mock_transaction]
modal.builder.submit_transaction = AsyncMock(return_value=[mock_transaction])
with patch('services.transaction_service.transaction_service') as mock_transaction_service:
# Mock the create_transaction_batch call
mock_transaction_service.create_transaction_batch = AsyncMock(return_value=[mock_transaction])
with patch('utils.transaction_logging.post_transaction_to_log') as mock_post_log:
mock_post_log.return_value = AsyncMock()
with patch('services.transaction_builder.clear_transaction_builder') as mock_clear:
await modal.on_submit(mock_interaction)
@ -273,6 +278,12 @@ class TestSubmitConfirmationModal:
# Should submit transaction for next week
modal.builder.submit_transaction.assert_called_once_with(week=11)
# Should mark transaction as frozen
assert mock_transaction.frozen is True
# Should POST to database
mock_transaction_service.create_transaction_batch.assert_called_once()
# Should clear builder
mock_clear.assert_called_once_with(123456789)
@ -290,9 +301,7 @@ class TestSubmitConfirmationModal:
modal.confirmation = MagicMock()
modal.confirmation.value = 'CONFIRM'
with patch('services.league_service.LeagueService') as mock_league_service_class:
mock_league_service = MagicMock()
mock_league_service_class.return_value = mock_league_service
with patch('services.league_service.league_service') as mock_league_service:
mock_league_service.get_current_state = AsyncMock(return_value=None)
await modal.on_submit(mock_interaction)

View File

@ -240,15 +240,22 @@ class SubmitConfirmationModal(discord.ui.Modal):
# Submit the transaction for NEXT week
transactions = await self.builder.submit_transaction(week=current_state.week + 1)
# Mark transactions as frozen for weekly processing
for txn in transactions:
txn.frozen = True
# POST transactions to database
created_transactions = await transaction_service.create_transaction_batch(transactions)
# Post to #transaction-log channel
bot = interaction.client
await post_transaction_to_log(bot, transactions, team=self.builder.team)
await post_transaction_to_log(bot, created_transactions, team=self.builder.team)
# Create success message
success_msg = f"✅ **Transaction Submitted Successfully!**\n\n"
success_msg += f"**Move ID:** `{transactions[0].moveid}`\n"
success_msg += f"**Moves:** {len(transactions)}\n"
success_msg += f"**Effective Week:** {transactions[0].week}\n\n"
success_msg += f"**Move ID:** `{created_transactions[0].moveid}`\n"
success_msg += f"**Moves:** {len(created_transactions)}\n"
success_msg += f"**Effective Week:** {created_transactions[0].week}\n\n"
success_msg += "**Transaction Details:**\n"
for move in self.builder.moves: