Replace all mock/placeholder data with real data systems
All checks were successful
Build And Push Image / docker (push) Successful in 2m13s
All checks were successful
Build And Push Image / docker (push) Successful in 2m13s
- Added getUserCount() method to Keycloak admin for real user statistics - Replaced hardcoded userCount (25) with live Keycloak data in admin stats - Fixed board meeting API to query real events, removed Jan 15 2025 fallback - Updated board stats to count real events instead of hardcoded 3 - Created member-tiers service for proper tier determination - Created dues-calculator service for accurate dues tracking - Updated auth callback to use member-tiers service - Updated overdue-count API to use dues-calculator - Added data quality tracking with confidence levels - Added proper error handling - returns null/0 instead of fake data - Included source tracking for all data (live/calculated/fallback) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
console.log('📊 Simple admin stats requested at:', new Date().toISOString());
|
||||
console.log('📊 Admin stats requested at:', new Date().toISOString());
|
||||
|
||||
try {
|
||||
// Check if user is admin
|
||||
@@ -17,17 +17,34 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
console.log('✅ Admin access verified for user:', session.user.email);
|
||||
|
||||
// Return simple user-focused stats without system metrics
|
||||
// Get real user count from Keycloak
|
||||
let userCount = 0;
|
||||
try {
|
||||
const { createKeycloakAdminClient } = await import('~/server/utils/keycloak-admin');
|
||||
const keycloakAdmin = createKeycloakAdminClient();
|
||||
userCount = await keycloakAdmin.getUserCount(false); // Exclude service accounts
|
||||
console.log('✅ Retrieved real user count from Keycloak:', userCount);
|
||||
} catch (keycloakError: any) {
|
||||
console.error('⚠️ Failed to get user count from Keycloak:', keycloakError);
|
||||
// Instead of returning mock data, return 0 or null to indicate data unavailable
|
||||
console.log('⚠️ User count unavailable, returning 0');
|
||||
userCount = 0;
|
||||
}
|
||||
|
||||
// Return stats with real data
|
||||
const stats = {
|
||||
// Simple user count (mock data for now - would come from Keycloak API)
|
||||
userCount: 25,
|
||||
// Real user count from Keycloak (0 if unavailable)
|
||||
userCount: userCount,
|
||||
|
||||
// Basic portal health without system metrics
|
||||
// Basic portal health
|
||||
portalStatus: 'online',
|
||||
lastUpdate: new Date().toISOString()
|
||||
lastUpdate: new Date().toISOString(),
|
||||
|
||||
// Add flag to indicate if data is from cache or live
|
||||
dataSource: userCount > 0 ? 'live' : 'unavailable'
|
||||
};
|
||||
|
||||
console.log('✅ Simple admin stats retrieved successfully');
|
||||
console.log('✅ Admin stats retrieved successfully:', stats);
|
||||
return stats;
|
||||
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in New Issue
Block a user