Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Latest commit

 

History

History
1 lines (1 loc) · 2.55 KB

File metadata and controls

1 lines (1 loc) · 2.55 KB

Tại Sao Cần Background Services Cho Giveth\n\n## 🎯 SCRIPT FIX CHỈ LÀ TEMPORARY SOLUTION\n\n### ❌ Script fix-all-materialized-views.js chỉ tạo FAKE DATA:\n- totalPower = 0.0 - Không có power calculations thực\n- user_project_power_view LIMIT 0 - Empty view\n- powerRank dựa trên project.id thay vì real power\n- Views tồn tại nhưng KHÔNG CÓ DATA THỰC\n\n### ✅ Services tạo REAL DATA:\n\n#### 1. Update Power Round Job (Quan trọng nhất)\n- File: src/services/cronJobs/updatePowerRoundJob.ts\n- Chức năng: \n - Fill power snapshots từ blockchain\n - Calculate real user GIVpower balances\n - Update project rankings dựa trên boosting thực\n - Refresh ALL materialized views với data thực\n\n#### 2. Instant Boosting Update Job\n- File: src/services/cronJobs/instantBoostingUpdateJob.ts \n- Chức năng:\n - Update real-time boosting data\n - Calculate instant power cho projects\n - Maintain project_instant_power_view với live data\n\n#### 3. Fill Power Snapshot Services\n- Files: powerSnapshotServices.ts\n- Chức năng:\n - Fetch user GIVpower balances từ blockchain\n - Store snapshot data trong database\n - Provide data cho power calculations\n\n#### 4. QF Round Services\n- File: checkActiveStatusQfRounds.ts\n- Chức năng:\n - Update matching fund calculations\n - Refresh project matching views\n - Handle quadratic funding rounds\n\n## 🔍 SO SÁNH DATA:\n\n### Script Fix (Fake Data):\nsql\nSELECT * FROM project_instant_power_view LIMIT 3;\n-- Result: totalPower = 0.0 cho tất cả projects\n\n\n### Services (Real Data):\nsql\n-- Sau khi services chạy:\n-- projectId | totalPower | powerRank\n-- 1001 | 12,456.78 | 1\n-- 1002 | 8,923.45 | 2 \n-- 1003 | 5,678.12 | 3\n\n\n## ⚡ TẠI SAO DEVELOPMENT DISABLE SERVICES:\n\n1. Performance: Services consume blockchain API calls\n2. Resources: Heavy database operations\n3. Dependencies: Cần blockchain node connections\n4. Cost: API calls cost money in development\n\n## 🎯 KẾT LUẬN:\n\n- Script fix: Chỉ để project pages không crash\n- Real functionality: Cần background services\n- Production: PHẢI enable services để có data thực\n- Development: Trade-off giữa stability vs real data\n\n### RECOMMENDATION:\n1. Phase 1: Dùng script fix cho stable development\n2. Phase 2: Enable key services cho real data\n3. Production: Enable tất cả services"