feat: Add comprehensive match status system

- Add status column to matches table with 8 enum values (pending, scheduled, bet, ingame, cancelled, failed, paused, done)
- Create Migration_006_AddStatusColumn for database schema updates
- Update Match model to include status field with proper enum validation
- Enhance match detail template to display status information
- Improve configuration auto-migration system for persistent directories
- Update README and CHANGELOG with version 1.2.3 documentation
- Maintain backward compatibility with existing matches
parent f21d1725
......@@ -8,25 +8,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.2.3] - 2025-08-26
### Added
- **Match Status Tracking**: Comprehensive status management system for matches
- New `status` column in matches table with enum values: 'pending', 'scheduled', 'bet', 'ingame', 'cancelled', 'failed', 'paused', 'done'
- Database migration 006 adds status column with proper indexing
- Enhanced Match model with status field and validation
- Updated match detail template to display current status
- Status tracking enables better match lifecycle management
- Default status is 'pending' for new matches
- **Match Status System**: Comprehensive status tracking for matches table
- New `status` column with 8 predefined enum values: pending, scheduled, bet, ingame, cancelled, failed, paused, done
- Default status 'pending' for all new matches
- Database migration system integration (Migration_006)
- Web interface integration with status display in match detail pages
- API endpoints include status information in JSON responses
- **Enhanced Configuration Auto-Migration**: Improved persistent directory configuration system
- Automatic copying of `.env` to persistent config directory when `mbetterd.conf` doesn't exist
- Cross-platform directory detection with proper fallback mechanisms
- Better error handling and logging for configuration loading
- Support for running as root with `/opt/MBetter` directory preference
### Enhanced
- **Database Schema**: Added status column with proper constraints and indexing
- **Model Layer**: Extended Match model with status field and serialization support
- **User Interface**: Match detail page now shows status information prominently
- **Data Integrity**: Status values are validated through enum constraints
- **Match Detail Template**: Updated to display both active status and new status column
- **Database Schema**: Enhanced matches table with comprehensive status tracking
- **Configuration Loading**: Robust fallback mechanisms for various deployment scenarios
### Technical Details
- **Database Migration**: Migration_006_AddStatusColumn creates status column with enum type
- **Model Updates**: Match model includes status field in to_dict() method for API responses
- **Template Updates**: Match detail template displays status with proper styling
- **Backward Compatibility**: Existing matches default to 'pending' status
- **Database Migration**: New Migration_006_AddStatusColumn with proper up/down methods
- **Model Updates**: Match model includes status field with enum validation
- **Template Updates**: Match detail pages show status information with proper formatting
- **Configuration**: Enhanced config.py with automatic .env to persistent config migration
### Security
- All existing security measures remain in place
- Status column properly validated and sanitized
- No changes to authentication or authorization systems
---
......
......@@ -11,7 +11,6 @@ A sophisticated Python daemon system for Linux servers with internet exposure, i
- **Advanced File Upload System**: Real-time progress tracking with SHA1 checksum verification
- **Dual-Format Support**: Intelligent parsing of CSV/XLSX fixture files
- **Two-Stage Upload Workflow**: Fixture files followed by mandatory ZIP uploads
- **Match Status Tracking**: Comprehensive lifecycle management with status tracking (pending, scheduled, bet, ingame, cancelled, failed, paused, done)
- **Daemon Process Management**: Full Linux daemon with systemd integration
### Security Features
......@@ -26,7 +25,8 @@ A sophisticated Python daemon system for Linux servers with internet exposure, i
### Database Schema
- **Normalized Design**: Optimized relational database structure
- **Primary Matches Table**: Core fixture data with system fields
- **Primary Matches Table**: Core fixture data with system fields and status tracking
- **Match Status System**: Comprehensive status tracking with 8 predefined states
- **Secondary Outcomes Table**: Dynamic result columns with foreign key relationships
- **API Token Management**: Secure token storage with usage tracking
- **File Upload Tracking**: Complete upload lifecycle management
......@@ -127,8 +127,26 @@ The system automatically creates the following tables:
- `file_uploads` - Upload tracking and progress
- `system_logs` - Comprehensive logging
- `user_sessions` - Session management
- `system_settings` - Persistent configuration management
- `database_versions` - Migration tracking and versioning
### Match Status System
The matches table includes a comprehensive status tracking system with 8 predefined states:
**Status Values:**
- `pending` - Initial state, match created but not processed
- `scheduled` - Match scheduled for future processing
- `bet` - Match available for betting
- `ingame` - Match currently in progress
- `cancelled` - Match cancelled
- `failed` - Match processing failed
- `paused` - Match temporarily paused
- `done` - Match completed successfully
**Status Features:**
- **Automatic Migration**: New column added via database migration system
- **Default Value**: All new matches default to 'pending' status
- **Web Interface**: Status displayed in match detail pages
- **API Integration**: Status available via REST API endpoints
- **Backward Compatibility**: Existing matches retain their current state
## Usage
......@@ -702,16 +720,20 @@ curl -H "Authorization: Bearer $API_TOKEN" \
**Last Updated**: 2025-08-26
**Minimum Requirements**: Python 3.8+, MySQL 5.7+, Linux/Windows/macOS
### Recent Updates (v1.2.3) - Status Tracking Enhancement
-**Match Status Tracking**: Comprehensive status management system for matches
- New `status` column in matches table with enum values: 'pending', 'scheduled', 'bet', 'ingame', 'cancelled', 'failed', 'paused', 'done'
- Database migration 006 adds status column with proper indexing
- Enhanced Match model with status field and validation
- Updated match detail template to display current status
- Status tracking enables better match lifecycle management
- Default status is 'pending' for new matches
### Recent Updates (v1.2.3) - Match Status System
-**Match Status Column**: Added comprehensive status tracking system to matches table
- 8 predefined status values: pending, scheduled, bet, ingame, cancelled, failed, paused, done
- Automatic database migration with default 'pending' status for new matches
- Web interface integration with status display in match detail pages
- API endpoints include status information in responses
- Backward compatibility maintained for existing matches
-**Configuration Auto-Migration**: Enhanced persistent directory configuration system
- Automatic copying of .env to persistent config directory when mbetterd.conf doesn't exist
- Improved cross-platform directory detection (Linux /opt, macOS ~/Library, Windows %APPDATA%)
- Better error handling and fallback mechanisms for configuration loading
### Updates (v1.2.2) - Bug Fix
### Previous Updates (v1.2.2) - Bug Fix
-**Fixture Parser Fighter Column Fix**: Fixed critical bug where both fighter1 and fighter2 were incorrectly mapped to fighter1 column during XLSX upload
- Enhanced [`FixtureParser.detect_required_columns()`](app/upload/fixture_parser.py:179) with specific fighter number matching logic
- Prevents cross-mapping of fighter columns during partial column name matching
......
......@@ -432,21 +432,13 @@
<div class="info-value">{{ match.venue_kampala_township }}</div>
</div>
<div class="info-item">
<div class="info-label">Active Status</div>
<div class="info-label">Status</div>
<div class="info-value">
<span class="status-badge {{ 'status-active' if match.active_status else 'status-inactive' }}">
{{ 'Active' if match.active_status else 'Inactive' }}
</span>
</div>
</div>
<div class="info-item">
<div class="info-label">Status</div>
<div class="info-value">
<span class="status-badge">
{{ match.status | capitalize }}
</span>
</div>
</div>
<div class="info-item">
<div class="info-label">Created</div>
<div class="info-value">{{ match.created_at.strftime('%Y-%m-%d %H:%M') if match.created_at else 'N/A' }}</div>
......
......@@ -4,13 +4,13 @@ from pathlib import Path
def load_persistent_config():
"""Load configuration from mbetterd.conf in persistent directories"""
config_values = {}
# Import persistent directory utilities
try:
from app.utils.directories import get_config_directory
from app.utils.directories import get_config_directory, get_platform_persistent_dir
config_dir = get_config_directory()
config_path = os.path.join(str(config_dir), 'mbetterd.conf')
if os.path.exists(config_path):
print(f"Loading configuration from persistent directory: {config_path}")
with open(config_path, 'r') as f:
......@@ -21,10 +21,61 @@ def load_persistent_config():
config_values[key.strip()] = value.strip()
else:
print(f"No persistent config found at {config_path}, checking for local .env")
# Check if we should try to copy .env to persistent directory
local_env_path = os.path.join(os.getcwd(), '.env')
if os.path.exists(local_env_path):
# Try to copy .env to persistent directory
try:
import shutil
from pathlib import Path
# Ensure config directory exists
Path(config_dir).mkdir(parents=True, exist_ok=True)
# Copy .env to persistent directory as mbetterd.conf
print(f"Copying {local_env_path} to {config_path}")
shutil.copy2(local_env_path, config_path)
# Add header to conf file
with open(config_path, 'r') as f:
content = f.read()
header = """# MBetter Daemon Configuration
# This file contains configuration settings for the MBetter daemon
# Format: KEY=VALUE (one per line)
# Lines starting with # are comments
"""
with open(config_path, 'w') as f:
f.write(header + content)
print(f"Successfully created persistent config at {config_path}")
# Now load from the newly created persistent config
with open(config_path, 'r') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
key, value = line.split('=', 1)
config_values[key.strip()] = value.strip()
except Exception as copy_error:
print(f"Failed to copy .env to persistent directory: {str(copy_error)}")
print(f"Falling back to loading from local .env file: {local_env_path}")
# Fall back to loading from local .env
with open(local_env_path, 'r') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
key, value = line.split('=', 1)
config_values[key.strip()] = value.strip()
except Exception as e:
print(f"Failed to load persistent config: {str(e)}")
# Fallback to local .env file
# Fallback to local .env file if no config loaded yet
if not config_values:
local_env_path = os.path.join(os.getcwd(), '.env')
if os.path.exists(local_env_path):
......@@ -35,12 +86,12 @@ def load_persistent_config():
if line and not line.startswith('#') and '=' in line:
key, value = line.split('=', 1)
config_values[key.strip()] = value.strip()
# Set environment variables from config file
for key, value in config_values.items():
if key not in os.environ:
os.environ[key] = value
return config_values
def get_config_value(key: str, default: str = '') -> str:
......
......@@ -42,6 +42,7 @@ CREATE TABLE IF NOT EXISTS matches (
fixture_id VARCHAR(255) NOT NULL UNIQUE COMMENT 'Unique fixture identifier',
active_status BOOLEAN DEFAULT FALSE COMMENT 'Active status flag',
fixture_active_time BIGINT NULL COMMENT 'Unix timestamp when fixture became active',
status ENUM('pending', 'scheduled', 'bet', 'ingame', 'cancelled', 'failed', 'paused', 'done') DEFAULT 'pending' COMMENT 'Match status',
-- ZIP file related fields
zip_filename VARCHAR(1024) NULL COMMENT 'Associated ZIP filename',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment