Add versioning and history tracking to usage statistics. Implement backup and conversion for old stats format, enhancing data structure for checkpoints and loras.

This commit is contained in:
Will Miao
2025-05-31 16:38:18 +08:00
parent 355c73512d
commit aa1ee96bc9
2 changed files with 134 additions and 27 deletions

View File

@@ -182,10 +182,14 @@ class MiscRoutes:
usage_stats = UsageStats()
stats = await usage_stats.get_stats()
return web.json_response({
# Add version information to help clients handle format changes
stats_response = {
'success': True,
'data': stats
})
'data': stats,
'format_version': 2 # Indicate this is the new format with history
}
return web.json_response(stats_response)
except Exception as e:
logger.error(f"Failed to get usage stats: {e}", exc_info=True)