Phase 6: Complete admin pages (Analytics, Monitor, Logs) and Phase 7: Asset management foundation
Phase 6 completion: - Add Analytics page with charts (user growth, revenue, retention) - Add SystemMonitor page (CPU, memory, services health) - Add LogViewer page (log search, filtering, details) - Update sidebar navigation with Admin submenu - Add recharts to package.json for data visualization Phase 7 Day 1-2: - Create Asset and AssetLibrary domain entities - Define AssetRepository and AssetLibraryRepository interfaces - Implement InMemory repositories for testing - Implement PostgreSQL repository adapter - Update SQLAlchemy models for assets and asset_libraries - Add database migration script 004_asset_management.sql Architecture: Strict Clean Architecture compliance Testing: InMemory adapters ready for unit tests Database: Migration script with indexes and foreign keys
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import sqlite3
|
||||
from datetime import datetime
|
||||
|
||||
# 删除旧数据库,重新创建
|
||||
conn = sqlite3.connect('/app/tracker.db')
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 删除所有表
|
||||
cursor.execute('DROP TABLE IF EXISTS tasks')
|
||||
cursor.execute('DROP TABLE IF EXISTS milestones')
|
||||
|
||||
# 重新创建表
|
||||
cursor.execute('''CREATE TABLE tasks (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
status TEXT DEFAULT 'pending',
|
||||
phase TEXT,
|
||||
milestone TEXT,
|
||||
priority TEXT DEFAULT 'medium',
|
||||
created_at TEXT,
|
||||
updated_at TEXT
|
||||
)''')
|
||||
|
||||
cursor.execute('''CREATE TABLE milestones (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
phase TEXT,
|
||||
start_date TEXT,
|
||||
end_date TEXT,
|
||||
status TEXT DEFAULT 'pending',
|
||||
description TEXT,
|
||||
created_at TEXT
|
||||
)''')
|
||||
|
||||
# Phase 4 已完成的任务(56个)
|
||||
phase4_tasks = [
|
||||
('JWT Service 实现', '实现 access token 和 refresh token', 'completed', 'high'),
|
||||
('Password Hasher 实现', 'bcrypt 密码加密 cost=12', 'completed', 'high'),
|
||||
('Redis Session Store', '基于 Redis 的 Session 存储', 'completed', 'high'),
|
||||
('Email Service 实现', 'SMTP 邮件服务', 'completed', 'high'),
|
||||
('用户注册 API', '用户注册接口', 'completed', 'high'),
|
||||
('邮箱验证 API', '邮箱验证接口', 'completed', 'high'),
|
||||
('用户登录 API', '用户登录接口', 'completed', 'high'),
|
||||
('用户登出 API', '用户登出接口', 'completed', 'high'),
|
||||
('密码重置 API', '密码重置流程', 'completed', 'medium'),
|
||||
('创建工作空间 API', '创建工作空间接口', 'completed', 'high'),
|
||||
('邀请成员 API', '邀请成员接口', 'completed', 'high'),
|
||||
('接受拒绝邀请 API', '处理邀请接口', 'completed', 'high'),
|
||||
('移除成员 API', '移除成员接口', 'completed', 'medium'),
|
||||
('离开工作空间 API', '成员离开接口', 'completed', 'medium'),
|
||||
('更新成员角色 API', '修改成员角色', 'completed', 'high'),
|
||||
('列出工作空间 API', '查询工作空间列表', 'completed', 'medium'),
|
||||
('工作空间详情 API', '工作空间详情', 'completed', 'medium'),
|
||||
('列出成员 API', '查询成员列表', 'completed', 'medium'),
|
||||
('Permission Checker', '权限检查器', 'completed', 'high'),
|
||||
('订阅计划定义', 'Free Pro Enterprise', 'completed', 'high'),
|
||||
('升级订阅 API', '订阅升级接口', 'completed', 'high'),
|
||||
('取消订阅 API', '订阅取消接口', 'completed', 'medium'),
|
||||
('配额检查工具', '配额管理工具', 'completed', 'high'),
|
||||
('UserRepository 接口', 'User 仓储接口', 'completed', 'high'),
|
||||
('UserRepository InMemory 实现', 'InMemory 实现', 'completed', 'high'),
|
||||
('WorkspaceRepository 接口', 'Workspace 仓储接口', 'completed', 'high'),
|
||||
('WorkspaceRepository InMemory 实现', 'InMemory 实现', 'completed', 'high'),
|
||||
('WorkspaceMemberRepository 接口', 'Member 仓储接口', 'completed', 'high'),
|
||||
('WorkspaceMemberRepository InMemory 实现', 'InMemory 实现', 'completed', 'high'),
|
||||
('WorkspaceInvitationRepository 接口', 'Invitation 仓储接口', 'completed', 'high'),
|
||||
('WorkspaceInvitationRepository InMemory 实现', 'InMemory 实现', 'completed', 'high'),
|
||||
('SubscriptionRepository 接口', 'Subscription 仓储接口', 'completed', 'high'),
|
||||
('SubscriptionRepository InMemory 实现', 'InMemory 实现', 'completed', 'high'),
|
||||
('PostgreSQL Repository 实现', 'PostgreSQL 数据库适配器', 'completed', 'high'),
|
||||
('Database Migration 脚本', '数据库迁移脚本', 'completed', 'high'),
|
||||
('FastAPI 路由层', 'API 路由实现', 'completed', 'high'),
|
||||
('API 文档 Swagger', 'Swagger 文档', 'completed', 'medium'),
|
||||
('错误处理中间件', '统一错误处理', 'completed', 'high'),
|
||||
('参数验证', 'Pydantic 参数验证', 'completed', 'high'),
|
||||
('Docker 配置', 'Docker Compose 配置', 'completed', 'high'),
|
||||
('Kubernetes 配置', 'K8s 部署配置', 'completed', 'medium'),
|
||||
('健康检查接口', 'Health Check API', 'completed', 'high'),
|
||||
('Celery Worker 配置', '异步任务配置', 'completed', 'medium'),
|
||||
('Redis 缓存集成', 'Redis 缓存', 'completed', 'high'),
|
||||
('GitHub Actions CI/CD', 'CI/CD 流水线', 'completed', 'high'),
|
||||
('单元测试 170个', '170 个单元测试', 'completed', 'high'),
|
||||
('集成测试', '12 个集成测试', 'completed', 'medium'),
|
||||
('性能测试', '性能测试用例', 'completed', 'medium'),
|
||||
('连接池优化', '5-6x 性能优化', 'completed', 'high'),
|
||||
('API 文档编写', 'API 使用文档', 'completed', 'medium'),
|
||||
('部署文档', '部署指南', 'completed', 'medium'),
|
||||
('开发文档', '开发指南', 'completed', 'medium'),
|
||||
('MIT 开源许可', 'MIT License', 'completed', 'low'),
|
||||
('README 完善', 'README.md', 'completed', 'medium'),
|
||||
('CONTRIBUTING 指南', '贡献指南', 'completed', 'low'),
|
||||
('CODE_OF_CONDUCT', '行为准则', 'completed', 'low'),
|
||||
]
|
||||
|
||||
# Phase 4 未完成的任务(4个)
|
||||
phase4_pending = [
|
||||
('文件上传 OSS', '阿里云 OSS 文件上传', 'pending', 'medium'),
|
||||
('搜索功能', '全文搜索', 'pending', 'medium'),
|
||||
('WebSocket 实时通信', 'WebSocket 支持', 'pending', 'low'),
|
||||
('Webhook 支持', 'Webhook 事件推送', 'pending', 'low'),
|
||||
]
|
||||
|
||||
now = datetime.now().isoformat()
|
||||
|
||||
# 插入 Phase 4 任务
|
||||
for name, desc, status, priority in phase4_tasks + phase4_pending:
|
||||
cursor.execute('''INSERT INTO tasks
|
||||
(name, description, status, phase, priority, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)''',
|
||||
(name, desc, status, 'Phase 4', priority, now, now))
|
||||
|
||||
# 插入里程碑
|
||||
milestones = [
|
||||
('认证与账号体系', 'Phase 4', '2026-06-17', '2026-06-17', 'completed', '用户注册登录密码管理'),
|
||||
('多租户权限体系', 'Phase 4', '2026-06-17', '2026-06-17', 'completed', '工作空间成员管理权限控制'),
|
||||
('订阅与计费体系', 'Phase 4', '2026-06-17', '2026-06-17', 'completed', '订阅计划配额管理'),
|
||||
('Repository 层', 'Phase 4', '2026-06-17', '2026-06-17', 'completed', '数据仓储层实现'),
|
||||
('API 层', 'Phase 4', '2026-06-17', '2026-06-17', 'completed', 'FastAPI 接口实现'),
|
||||
('测试与部署', 'Phase 4', '2026-06-17', '2026-06-17', 'completed', '测试 Docker CI/CD'),
|
||||
]
|
||||
|
||||
for name, phase, start, end, status, desc in milestones:
|
||||
cursor.execute('''INSERT INTO milestones
|
||||
(name, phase, start_date, end_date, status, description, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)''',
|
||||
(name, phase, start, end, status, desc, now))
|
||||
|
||||
conn.commit()
|
||||
|
||||
# 验证
|
||||
cursor.execute('SELECT COUNT(*) FROM tasks WHERE status = "completed"')
|
||||
completed = cursor.fetchone()[0]
|
||||
cursor.execute('SELECT COUNT(*) FROM tasks')
|
||||
total = cursor.fetchone()[0]
|
||||
|
||||
print(f'✅ Tracker 修复完成!')
|
||||
print(f' - 总任务数: {total}')
|
||||
print(f' - 已完成: {completed}')
|
||||
print(f' - 待完成: {total - completed}')
|
||||
print(f' - 完成率: {completed/total*100:.1f}%')
|
||||
|
||||
# 测试中文显示
|
||||
cursor.execute('SELECT name FROM tasks LIMIT 3')
|
||||
print(f'\n前3个任务:')
|
||||
for row in cursor.fetchall():
|
||||
print(f' - {row[0]}')
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user