|
| 1 | +# REST API Plugin Changelog |
| 2 | + |
| 3 | +This document tracks all notable changes made to the REST API plugin. |
| 4 | + |
| 5 | +## [Unreleased] - 2025-12-26 |
| 6 | + |
| 7 | +### 🆕 Added |
| 8 | + |
| 9 | +#### Weather Integration in `/servers` Endpoint |
| 10 | +- **Comprehensive weather data**: Temperature, wind speed/direction, pressure, visibility, cloud coverage |
| 11 | +- **Real-time DCS integration**: Weather extracted from active mission weather system |
| 12 | +- **Configurable**: Control via `include_weather` setting (default: true) |
| 13 | + |
| 14 | +#### New `/server_attendance` Endpoint |
| 15 | +- **Multi-period analytics**: 24h, 7d, 30d player statistics with Discord member engagement |
| 16 | +- **Enhanced server insights**: Top theatres, missions, and modules by playtime and usage |
| 17 | +- **Combat statistics**: Total sorties, kills, deaths, PvP metrics from mv_serverstats |
| 18 | +- **Daily trends**: 7-day player activity trends for graphing |
| 19 | +- **Inspired by Discord `/serverstats`**: Comprehensive data matching monitoring plugin functionality |
| 20 | + |
| 21 | +#### Configuration Options |
| 22 | +- `include_weather: true/false` - Toggle weather in server responses |
| 23 | +- `server_attendance.enabled: true/false` - Enable attendance analytics endpoint |
| 24 | + |
| 25 | +### 🔄 Changed |
| 26 | + |
| 27 | +#### Centralized Server Name Resolution |
| 28 | +- **Unified server handling**: All endpoints now use centralized `get_resolved_server()` method |
| 29 | +- **Alias support**: Endpoints support both instance aliases (nodes.yaml) and full DCS server names (servers.yaml) |
| 30 | +- **Affected endpoints**: `/serverstats`, `/leaderboard`, `/topkills`, `/topkdr`, `/trueskill`, `/highscore`, `/weaponpk`, `/stats`, `/modulestats`, `/traps`, `/server_attendance` |
| 31 | + |
| 32 | +#### Code Architecture Improvements |
| 33 | +- **Simplified SQL construction**: Removed overly complex `get_server_where_clause_and_params()` helper |
| 34 | +- **Readable patterns**: Straightforward conditional SQL with direct parameter passing |
| 35 | +- **Better maintainability**: Clear, transparent code structure while preserving functionality |
| 36 | + |
| 37 | +### 🐛 Fixed |
| 38 | + |
| 39 | +#### Endpoint Corrections |
| 40 | +- **`/modulestats` endpoint**: Fixed incorrect method mapping (`self.stats` → `self.modulestats`) and response model (`ModuleStats` → `list[ModuleStats]`) |
| 41 | +- **SQL syntax errors**: Resolved parameter binding issues in database queries |
| 42 | +- **Weather data extraction**: Corrected data structure parsing from DCS mission weather |
| 43 | + |
| 44 | +#### Data Model Validation |
| 45 | +- **Response validation**: Fixed Pydantic model validation errors |
| 46 | +- **Type consistency**: Proper typing for all new data structures |
| 47 | + |
| 48 | +### 📊 Enhanced Data Models |
| 49 | + |
| 50 | +#### New Pydantic Models |
| 51 | +```python |
| 52 | +# Weather information |
| 53 | +class WeatherInfo(BaseModel): |
| 54 | + temperature: float | None |
| 55 | + wind_speed: float | None |
| 56 | + wind_direction: int | None |
| 57 | + pressure: float | None |
| 58 | + visibility: float | None |
| 59 | + cloud_coverage: str | None |
| 60 | + |
| 61 | +# Top statistics for server attendance |
| 62 | +class TopTheatre(BaseModel): |
| 63 | + theatre: str |
| 64 | + playtime_hours: int |
| 65 | + |
| 66 | +class TopMission(BaseModel): |
| 67 | + mission_name: str |
| 68 | + playtime_hours: int |
| 69 | + |
| 70 | +class TopModule(BaseModel): |
| 71 | + module: str |
| 72 | + playtime_hours: int |
| 73 | + unique_players: int |
| 74 | + total_uses: int |
| 75 | + |
| 76 | +# Enhanced server attendance with comprehensive analytics |
| 77 | +class ServerAttendanceStats(BaseModel): |
| 78 | + current_players: int |
| 79 | + unique_players_24h: int |
| 80 | + total_playtime_hours_24h: float |
| 81 | + discord_members_24h: int |
| 82 | + unique_players_7d: int |
| 83 | + total_playtime_hours_7d: float |
| 84 | + discord_members_7d: int |
| 85 | + unique_players_30d: int |
| 86 | + total_playtime_hours_30d: float |
| 87 | + discord_members_30d: int |
| 88 | + daily_trend: list[dict] |
| 89 | + top_theatres: list[TopTheatre] |
| 90 | + top_missions: list[TopMission] |
| 91 | + top_modules: list[TopModule] |
| 92 | + total_sorties: int | None |
| 93 | + total_kills: int | None |
| 94 | + total_deaths: int | None |
| 95 | + total_pvp_kills: int | None |
| 96 | + total_pvp_deaths: int | None |
| 97 | +``` |
| 98 | + |
| 99 | +### 🚀 Performance & Technical Details |
| 100 | + |
| 101 | +#### Database Integration |
| 102 | +- **Monitoring plugin patterns**: Leverages existing monitoring infrastructure SQL queries |
| 103 | +- **Materialized views**: Efficient use of `mv_serverstats` for performance |
| 104 | +- **Optimized queries**: Following established DCS server integration patterns |
| 105 | + |
| 106 | +#### Backward Compatibility |
| 107 | +- **Zero breaking changes**: All existing API consumers continue working unchanged |
| 108 | +- **Opt-in features**: New functionality enabled by default but configurable |
| 109 | +- **Migration-free**: No configuration changes required for existing setups |
| 110 | + |
| 111 | +### 📈 Impact |
| 112 | + |
| 113 | +#### For API Consumers |
| 114 | +- **Richer server data**: Weather and comprehensive attendance analytics |
| 115 | +- **Better server identification**: Flexible server name resolution (aliases + full names) |
| 116 | +- **Enhanced dashboards**: More detailed metrics for monitoring and visualization |
| 117 | + |
| 118 | +#### For Developers |
| 119 | +- **Cleaner codebase**: Simplified, maintainable SQL construction patterns |
| 120 | +- **Consistent patterns**: Unified server resolution across all endpoints |
| 121 | +- **Better documentation**: Complete API models with examples and validation |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +**Summary**: This release significantly enhances the REST API plugin with comprehensive server analytics, weather integration, and improved code architecture while maintaining full backward compatibility. |
0 commit comments