feat(platform): Complete Postgres-Only architecture refactoring (Phase 1-7)
Major Changes: - Implement Platform-Only architecture pattern (unified task management) - Add PostgresCacheAdapter for unified caching (platform_schema.app_cache) - Add PgBossQueue for job queue management (platform_schema.job) - Implement CheckpointService using job.data (generic for all modules) - Add intelligent threshold-based dual-mode processing (THRESHOLD=50) - Add task splitting mechanism (auto chunk size recommendation) - Refactor ASL screening service with smart mode selection - Refactor DC extraction service with smart mode selection - Register workers for ASL and DC modules Technical Highlights: - All task management data stored in platform_schema.job.data (JSONB) - Business tables remain clean (no task management fields) - CheckpointService is generic (shared by all modules) - Zero code duplication (DRY principle) - Follows 3-layer architecture principle - Zero additional cost (no Redis needed, save 8400 CNY/year) Code Statistics: - New code: ~1750 lines - Modified code: ~500 lines - Test code: ~1800 lines - Documentation: ~3000 lines Testing: - Unit tests: 8/8 passed - Integration tests: 2/2 passed - Architecture validation: passed - Linter errors: 0 Files: - Platform layer: PostgresCacheAdapter, PgBossQueue, CheckpointService, utils - ASL module: screeningService, screeningWorker - DC module: ExtractionController, extractionWorker - Tests: 11 test files - Docs: Updated 4 key documents Status: Phase 1-7 completed, Phase 8-9 pending
This commit is contained in:
85
backend/src/tests/verify-test1-database.sql
Normal file
85
backend/src/tests/verify-test1-database.sql
Normal file
@@ -0,0 +1,85 @@
|
||||
-- ============================================
|
||||
-- 验证测试1的数据库状态
|
||||
-- ============================================
|
||||
|
||||
\echo '=========================================='
|
||||
\echo '1. 检查 app_cache 表是否存在'
|
||||
\echo '=========================================='
|
||||
\dt platform_schema.app_cache
|
||||
|
||||
\echo ''
|
||||
\echo '=========================================='
|
||||
\echo '2. 查看表结构'
|
||||
\echo '=========================================='
|
||||
\d platform_schema.app_cache
|
||||
|
||||
\echo ''
|
||||
\echo '=========================================='
|
||||
\echo '3. 查看索引'
|
||||
\echo '=========================================='
|
||||
SELECT indexname, indexdef
|
||||
FROM pg_indexes
|
||||
WHERE schemaname = 'platform_schema'
|
||||
AND tablename = 'app_cache';
|
||||
|
||||
\echo ''
|
||||
\echo '=========================================='
|
||||
\echo '4. 检查测试数据是否清理(应为0行)'
|
||||
\echo '=========================================='
|
||||
SELECT COUNT(*) as test_data_count
|
||||
FROM platform_schema.app_cache
|
||||
WHERE key LIKE 'test:%';
|
||||
|
||||
\echo ''
|
||||
\echo '=========================================='
|
||||
\echo '5. 查看所有缓存数据'
|
||||
\echo '=========================================='
|
||||
SELECT id, key,
|
||||
LEFT(value::text, 50) as value_preview,
|
||||
expires_at,
|
||||
created_at
|
||||
FROM platform_schema.app_cache
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 10;
|
||||
|
||||
\echo ''
|
||||
\echo '=========================================='
|
||||
\echo '6. 查看表统计信息'
|
||||
\echo '=========================================='
|
||||
SELECT
|
||||
COUNT(*) as total_records,
|
||||
pg_size_pretty(pg_total_relation_size('platform_schema.app_cache')) as total_size,
|
||||
pg_size_pretty(pg_relation_size('platform_schema.app_cache')) as table_size,
|
||||
pg_size_pretty(pg_indexes_size('platform_schema.app_cache')) as indexes_size
|
||||
FROM platform_schema.app_cache;
|
||||
|
||||
\echo ''
|
||||
\echo '=========================================='
|
||||
\echo '7. 测试写入和删除(不会影响现有数据)'
|
||||
\echo '=========================================='
|
||||
|
||||
-- 插入测试数据
|
||||
INSERT INTO platform_schema.app_cache (key, value, expires_at, created_at)
|
||||
VALUES ('verify_test', '{"status": "ok"}', NOW() + INTERVAL '1 hour', NOW());
|
||||
|
||||
-- 验证插入
|
||||
SELECT 'INSERT 成功' as result
|
||||
FROM platform_schema.app_cache
|
||||
WHERE key = 'verify_test';
|
||||
|
||||
-- 删除测试数据
|
||||
DELETE FROM platform_schema.app_cache WHERE key = 'verify_test';
|
||||
|
||||
-- 验证删除
|
||||
SELECT CASE
|
||||
WHEN COUNT(*) = 0 THEN 'DELETE 成功'
|
||||
ELSE 'DELETE 失败'
|
||||
END as result
|
||||
FROM platform_schema.app_cache
|
||||
WHERE key = 'verify_test';
|
||||
|
||||
\echo ''
|
||||
\echo '=========================================='
|
||||
\echo '✅ 数据库验证完成!'
|
||||
\echo '=========================================='
|
||||
|
||||
Reference in New Issue
Block a user