feat: add participant data persistence display and mobile responsive fixes

- Add getStats() method to participantService for tag distribution
- Update participants API to return tagDistribution statistics
- Load existing participants on AdminControl mount
- Add mobile responsive styles for import section

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
empty
2026-01-25 22:02:12 +08:00
parent 96b428e64a
commit 7dc77da939
3 changed files with 81 additions and 3 deletions

View File

@@ -137,15 +137,17 @@ router.post('/participants/import', upload.single('file'), async (req, res, next
/**
* GET /api/admin/participants
* Get all participants
* Get all participants with statistics
*/
router.get('/participants', async (_req, res, next) => {
try {
const participants = participantService.getAll();
const stats = participantService.getStats();
return res.json({
success: true,
data: {
count: participants.length,
tagDistribution: stats.tagDistribution,
participants,
},
});

View File

@@ -232,6 +232,22 @@ class ParticipantService {
return this.participants.size;
}
/**
* Get statistics including tag distribution
*/
getStats(): { count: number; tagDistribution: Record<string, number> } {
const tagDistribution: Record<string, number> = {};
for (const p of this.participants.values()) {
for (const tag of p.tags) {
tagDistribution[tag] = (tagDistribution[tag] || 0) + 1;
}
}
return {
count: this.participants.size,
tagDistribution,
};
}
/**
* Save participants to Redis for persistence
*/