feat: optimización integral y auditoría de rendimiento SIBU 2.0.1

This commit is contained in:
2026-03-01 17:35:13 -05:00
parent 66b76cee61
commit 6ae0e7b0bf
14 changed files with 917 additions and 2170 deletions

View File

@ -15,6 +15,7 @@ export const useBusStopStore = defineStore('busStop', () => {
const CACHE_TIME = 1000 * 60 * 30; // 30 minutos
const now = Date.now();
if (isLoading.value) return;
if (!force && busStops.value.length > 0 && (now - lastFetched.value < CACHE_TIME)) {
return
}
@ -33,6 +34,7 @@ export const useBusStopStore = defineStore('busStop', () => {
}
async function loadBusStopById(id: string, force = false) {
if (isLoading.value) return;
// Buscar en cache primero
if (!force && busStops.value.length > 0) {
const cachedStop = busStops.value.find(s => s.id === id);

View File

@ -12,6 +12,7 @@ export const useCouponStore = defineStore('coupon', () => {
const filters = ref<CouponFilters>({})
async function loadCoupons(newFilters?: CouponFilters) {
if (isLoading.value) return;
isLoading.value = true
error.value = null
if (newFilters) {

View File

@ -22,6 +22,9 @@ export const useRouteStore = defineStore('route', () => {
const CACHE_TIME = 1000 * 60 * 15; // 15 minutos
const now = Date.now();
// Guard: Si ya se están cargando rutas, no iniciar otra petición
if (isLoadingRoutes.value) return;
// Si no forzamos, no hay filtros raros, ya tenemos rutas y aún no expira el caché, omitir llamada
if (!force && !filters && allRoutes.value.length > 0 && (now - lastFetched.value < CACHE_TIME)) {
return
@ -44,6 +47,7 @@ export const useRouteStore = defineStore('route', () => {
const CACHE_TIME = 1000 * 60 * 15; // 15 minutos
const now = Date.now();
if (isLoadingStops.value) return;
if (!force && stopsCache.value.has(routeId)) {
const cacheEntry = stopsCache.value.get(routeId)!;
if (now - cacheEntry.fetchedAt < CACHE_TIME) {