feat: optimización integral y auditoría de rendimiento SIBU 2.0.1
This commit is contained in:
@ -263,11 +263,13 @@ const maxStopCount = computed(() => {
|
||||
return Math.max(...stats.value.top_stops.map((s: any) => s.count));
|
||||
});
|
||||
|
||||
import jsPDF from 'jspdf';
|
||||
import html2canvas from 'html2canvas';
|
||||
|
||||
const generateReport = async () => {
|
||||
// const loadingNotify = ref(true); // Podríamos añadir un pequeño indicator de "Generando..."
|
||||
// OPTIMIZACIÓN: Carga dinámica de librerías pesadas para no afectar el rendimiento inicial
|
||||
const [{ jsPDF }, html2canvas] = await Promise.all([
|
||||
import('jspdf'),
|
||||
import('html2canvas').then(m => m.default)
|
||||
]);
|
||||
|
||||
const date = new Date().toLocaleDateString('es-ES', { month: 'long', year: 'numeric' });
|
||||
const doc = new jsPDF('p', 'mm', 'a4');
|
||||
const pageWidth = doc.internal.pageSize.getWidth();
|
||||
@ -393,25 +395,29 @@ const getHealthLabel = (rate: any) => (parseFloat(rate) > 20 ? 'Alta' : parseFlo
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
// Get user count
|
||||
const { count: userCount } = await supabase.from('users').select('*', { count: 'exact', head: true }).eq('is_active', true)
|
||||
// Load all data in parallel
|
||||
const [
|
||||
{ count: userCount },
|
||||
{ data: shuttles },
|
||||
{ data: routes },
|
||||
{ data: businesses }
|
||||
] = await Promise.all([
|
||||
supabase.from('users').select('*', { count: 'exact', head: true }).eq('is_active', true),
|
||||
supabase.from('shuttles').select('id, route_name'),
|
||||
supabase.from('routes').select('id, name'),
|
||||
supabase.from('businesses').select('id, name')
|
||||
])
|
||||
|
||||
// Get shuttle stats
|
||||
const { data: shuttles } = await supabase.from('shuttles').select('id, route_name')
|
||||
const shuttleStats: any = {}
|
||||
for (const s of (shuttles || [])) {
|
||||
shuttleStats[s.route_name || s.id] = { views: Math.floor(Math.random() * 100), contacts: Math.floor(Math.random() * 20) }
|
||||
}
|
||||
|
||||
// Get route stats
|
||||
const { data: routes } = await supabase.from('routes').select('id, name')
|
||||
const routeStats: any = {}
|
||||
for (const r of (routes || [])) {
|
||||
routeStats[r.name || r.id] = { views: Math.floor(Math.random() * 80), contacts: Math.floor(Math.random() * 15) }
|
||||
}
|
||||
|
||||
// Get business stats
|
||||
const { data: businesses } = await supabase.from('businesses').select('id, name')
|
||||
const bizStats: any = {}
|
||||
for (const b of (businesses || [])) {
|
||||
bizStats[b.name || b.id] = { views: Math.floor(Math.random() * 60), promos: Math.floor(Math.random() * 10) }
|
||||
|
||||
Reference in New Issue
Block a user