feat: Add match status tracking system

- Add status column to matches table with enum values (pending, scheduled, bet, ingame, cancelled, failed, paused, done)
- Implement database migration 006 for status tracking
- Update Match model with status field and validation
- Enhance match detail template to display status information
- Update documentation (README and CHANGELOG) for v1.2.3
- Enable comprehensive match lifecycle management
parent b7912d69
......@@ -5,6 +5,31 @@ All notable changes to the Fixture Manager daemon project will be documented in
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [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
### 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
### 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
---
## [1.2.2] - 2025-08-21
### Fixed
......
......@@ -11,6 +11,7 @@ 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
......@@ -120,12 +121,14 @@ DEBUG=false
### Database Schema
The system automatically creates the following tables:
- `users` - User authentication and management
- `matches` - Core fixture data with system fields
- `matches` - Core fixture data with system fields and status tracking
- `match_outcomes` - Dynamic outcome results
- `api_tokens` - User-generated API tokens for external access
- `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
## Usage
......@@ -695,11 +698,20 @@ curl -H "Authorization: Bearer $API_TOKEN" \
---
**Version**: 1.2.2
**Last Updated**: 2025-08-21
**Version**: 1.2.3
**Last Updated**: 2025-08-26
**Minimum Requirements**: Python 3.8+, MySQL 5.7+, Linux/Windows/macOS
### Recent Updates (v1.2.2) - Bug Fix
### 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
### 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
......
......@@ -317,6 +317,65 @@ class Migration_005_AddFixtureActiveTime(Migration):
def can_rollback(self) -> bool:
return True
class Migration_006_AddStatusColumn(Migration):
"""Add status column to matches table"""
def __init__(self):
super().__init__("006", "Add status column to matches table")
def up(self):
"""Add status column"""
try:
# Check if column already exists
inspector = inspect(db.engine)
columns = [col['name'] for col in inspector.get_columns('matches')]
if 'status' in columns:
logger.info("status column already exists, skipping creation")
return True
# Add the column
alter_table_sql = '''
ALTER TABLE matches
ADD COLUMN status ENUM('pending', 'scheduled', 'bet', 'ingame', 'cancelled', 'failed', 'paused', 'done') DEFAULT 'pending'
'''
with db.engine.connect() as conn:
conn.execute(text(alter_table_sql))
conn.commit()
# Create index for performance
create_index_sql = '''
CREATE INDEX idx_matches_status ON matches(status)
'''
with db.engine.connect() as conn:
conn.execute(text(create_index_sql))
conn.commit()
logger.info("Added status column and index successfully")
return True
except Exception as e:
logger.error(f"Migration 006 failed: {str(e)}")
raise
def down(self):
"""Drop status column"""
try:
with db.engine.connect() as conn:
conn.execute(text("DROP INDEX IF EXISTS idx_matches_status"))
conn.execute(text("ALTER TABLE matches DROP COLUMN IF EXISTS status"))
conn.commit()
logger.info("Dropped status column and index")
return True
except Exception as e:
logger.error(f"Rollback of migration 006 failed: {str(e)}")
raise
def can_rollback(self) -> bool:
return True
class MigrationManager:
"""Manages database migrations and versioning"""
......@@ -327,6 +386,7 @@ class MigrationManager:
Migration_003_CreateAPITokensTable(),
Migration_004_CreateSystemSettingsTable(),
Migration_005_AddFixtureActiveTime(),
Migration_006_AddStatusColumn(),
]
def ensure_version_table(self):
......
......@@ -126,6 +126,10 @@ class Match(db.Model):
# Fixture active time (unix timestamp when all matches in fixture become active)
fixture_active_time = db.Column(db.BigInteger, nullable=True, index=True)
# Status column
status = db.Column(db.Enum('pending', 'scheduled', 'bet', 'ingame', 'cancelled', 'failed', 'paused', 'done', name='match_status'),
default='pending', index=True)
# ZIP file related fields
zip_filename = db.Column(db.String(1024))
zip_sha1sum = db.Column(db.String(255), index=True)
......@@ -351,6 +355,7 @@ class Match(db.Model):
'file_sha1sum': self.file_sha1sum,
'fixture_id': self.fixture_id,
'active_status': self.active_status,
'status': self.status,
'zip_filename': self.zip_filename,
'zip_sha1sum': self.zip_sha1sum,
'zip_upload_status': self.zip_upload_status,
......
......@@ -432,13 +432,21 @@
<div class="info-value">{{ match.venue_kampala_township }}</div>
</div>
<div class="info-item">
<div class="info-label">Status</div>
<div class="info-label">Active 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>
......
......@@ -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