mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-03-28 17:42:45 +01:00
Implements automatic daily archiving of messages to improve performance
and enable browsing historical chat by date.
Backend changes:
- Add APScheduler for daily archiving at midnight (00:00 UTC)
- Create app/archiver/manager.py with archive logic and scheduler
- Extend parser.py to read from archive files and filter by days
- Add archive configuration to config.py (MC_ARCHIVE_*)
API changes:
- Extend GET /api/messages with archive_date and days parameters
- Add GET /api/archives endpoint to list available archives
- Add POST /api/archive/trigger for manual archiving
Frontend changes:
- Add date selector dropdown in navbar for archive browsing
- Implement archive list loading and date selection
- Update formatTime() to show full dates in archive view
- Live view now shows only last 7 days (configurable)
Docker & Config:
- Add archive volume mount in docker-compose.yml
- Add MC_ARCHIVE_DIR, MC_ARCHIVE_ENABLED, MC_ARCHIVE_RETENTION_DAYS env vars
- Update .env.example with archive configuration section
Documentation:
- Update README.md with archive feature and usage instructions
- Update .claude/instructions.md with archive endpoints
Key features:
- Automatic daily archiving (midnight UTC)
- Live view filtered to last 7 days for better performance
- Browse historical messages by date via dropdown selector
- Archives stored as dated files: {device}.YYYY-MM-DD.msgs
- Original .msgs file never modified (safe, read-only approach)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
"""
|
|
Configuration module - loads settings from environment variables
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
class Config:
|
|
"""Application configuration from environment variables"""
|
|
|
|
# MeshCore device configuration
|
|
MC_SERIAL_PORT = os.getenv('MC_SERIAL_PORT', '/dev/ttyUSB0')
|
|
MC_DEVICE_NAME = os.getenv('MC_DEVICE_NAME', 'MeshCore')
|
|
MC_CONFIG_DIR = os.getenv('MC_CONFIG_DIR', '/root/.config/meshcore')
|
|
|
|
# Application settings
|
|
MC_REFRESH_INTERVAL = int(os.getenv('MC_REFRESH_INTERVAL', '60'))
|
|
MC_INACTIVE_HOURS = int(os.getenv('MC_INACTIVE_HOURS', '48'))
|
|
|
|
# Archive configuration
|
|
MC_ARCHIVE_DIR = os.getenv('MC_ARCHIVE_DIR', '/root/.archive/meshcore')
|
|
MC_ARCHIVE_ENABLED = os.getenv('MC_ARCHIVE_ENABLED', 'true').lower() == 'true'
|
|
MC_ARCHIVE_RETENTION_DAYS = int(os.getenv('MC_ARCHIVE_RETENTION_DAYS', '7'))
|
|
|
|
# Flask server configuration
|
|
FLASK_HOST = os.getenv('FLASK_HOST', '0.0.0.0')
|
|
FLASK_PORT = int(os.getenv('FLASK_PORT', '5000'))
|
|
FLASK_DEBUG = os.getenv('FLASK_DEBUG', 'false').lower() == 'true'
|
|
|
|
# Derived paths
|
|
@property
|
|
def msgs_file_path(self) -> Path:
|
|
"""Get the full path to the .msgs file"""
|
|
return Path(self.MC_CONFIG_DIR) / f"{self.MC_DEVICE_NAME}.msgs"
|
|
|
|
@property
|
|
def meshcli_command(self) -> list:
|
|
"""Get the base meshcli command with serial port"""
|
|
return ['meshcli', '-s', self.MC_SERIAL_PORT]
|
|
|
|
@property
|
|
def archive_dir_path(self) -> Path:
|
|
"""Get the full path to archive directory"""
|
|
return Path(self.MC_ARCHIVE_DIR)
|
|
|
|
def __repr__(self):
|
|
return (
|
|
f"Config(device={self.MC_DEVICE_NAME}, "
|
|
f"port={self.MC_SERIAL_PORT}, "
|
|
f"config_dir={self.MC_CONFIG_DIR})"
|
|
)
|
|
|
|
|
|
# Global config instance
|
|
config = Config()
|