Enhance caching mechanism and logging configuration

- Updated .gitignore to include additional IDE and OS files, as well as log and web build directories.
- Expanded config.sample.yaml to include cache configuration options for memory and Redis.
- Modified wallamonitor.py to load cache configuration and initialize ArticleCache.
- Refactored QueueManager to utilize ArticleCache for tracking notified articles.
- Improved logging setup to dynamically determine log file path based on environment.
This commit is contained in:
Omar Sánchez Pizarro
2026-01-19 19:42:12 +01:00
parent b32b0b2e09
commit 9939c4d9ed
41 changed files with 6742 additions and 28 deletions

View File

@@ -0,0 +1,178 @@
<template>
<div>
<h1 class="text-3xl font-bold text-gray-900 mb-6">Dashboard</h1>
<!-- Estadísticas -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
<div class="card">
<div class="flex items-center">
<div class="flex-shrink-0 bg-primary-100 rounded-lg p-3">
<Cog6ToothIcon class="w-6 h-6 text-primary-600" />
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Workers Activos</p>
<p class="text-2xl font-bold text-gray-900">{{ stats.activeWorkers }}/{{ stats.totalWorkers }}</p>
</div>
</div>
</div>
<div class="card">
<div class="flex items-center">
<div class="flex-shrink-0 bg-green-100 rounded-lg p-3">
<HeartIcon class="w-6 h-6 text-green-600" />
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Favoritos</p>
<p class="text-2xl font-bold text-gray-900">{{ stats.totalFavorites }}</p>
</div>
</div>
</div>
<div class="card">
<div class="flex items-center">
<div class="flex-shrink-0 bg-blue-100 rounded-lg p-3">
<DocumentTextIcon class="w-6 h-6 text-blue-600" />
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Artículos Notificados</p>
<p class="text-2xl font-bold text-gray-900">{{ stats.totalNotified }}</p>
</div>
</div>
</div>
<div class="card">
<div class="flex items-center">
<div class="flex-shrink-0 bg-purple-100 rounded-lg p-3">
<ChartBarIcon class="w-6 h-6 text-purple-600" />
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Plataformas</p>
<p class="text-sm font-bold text-gray-900">
W: {{ stats.platforms?.wallapop || 0 }} | V: {{ stats.platforms?.vinted || 0 }}
</p>
</div>
</div>
</div>
</div>
<!-- Gráfico de plataformas -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="card">
<h2 class="text-xl font-bold text-gray-900 mb-4">Distribución por Plataforma</h2>
<div class="space-y-4">
<div>
<div class="flex justify-between mb-2">
<span class="text-sm font-medium text-gray-700">Wallapop</span>
<span class="text-sm font-medium text-gray-900">{{ stats.platforms?.wallapop || 0 }}</span>
</div>
<div class="w-full bg-gray-200 rounded-full h-2">
<div
class="bg-primary-600 h-2 rounded-full"
:style="{
width: `${getPercentage(stats.platforms?.wallapop || 0, stats.totalNotified)}%`,
}"
></div>
</div>
</div>
<div>
<div class="flex justify-between mb-2">
<span class="text-sm font-medium text-gray-700">Vinted</span>
<span class="text-sm font-medium text-gray-900">{{ stats.platforms?.vinted || 0 }}</span>
</div>
<div class="w-full bg-gray-200 rounded-full h-2">
<div
class="bg-green-600 h-2 rounded-full"
:style="{
width: `${getPercentage(stats.platforms?.vinted || 0, stats.totalNotified)}%`,
}"
></div>
</div>
</div>
</div>
</div>
<div class="card">
<h2 class="text-xl font-bold text-gray-900 mb-4">Accesos Rápidos</h2>
<div class="space-y-3">
<router-link
to="/articles"
class="flex items-center justify-between p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors"
>
<span class="text-sm font-medium text-gray-700">Ver todos los artículos</span>
<ArrowRightIcon class="w-5 h-5 text-gray-400" />
</router-link>
<router-link
to="/favorites"
class="flex items-center justify-between p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors"
>
<span class="text-sm font-medium text-gray-700">Ver favoritos</span>
<ArrowRightIcon class="w-5 h-5 text-gray-400" />
</router-link>
<router-link
to="/workers"
class="flex items-center justify-between p-3 bg-gray-50 rounded-lg hover:bg-gray-100 transition-colors"
>
<span class="text-sm font-medium text-gray-700">Gestionar workers</span>
<ArrowRightIcon class="w-5 h-5 text-gray-400" />
</router-link>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import api from '../services/api';
import {
Cog6ToothIcon,
HeartIcon,
DocumentTextIcon,
ChartBarIcon,
ArrowRightIcon,
} from '@heroicons/vue/24/outline';
const stats = ref({
totalWorkers: 0,
activeWorkers: 0,
totalFavorites: 0,
totalNotified: 0,
platforms: {},
});
function getPercentage(value, total) {
if (!total || total === 0) return 0;
return Math.round((value / total) * 100);
}
async function loadStats() {
try {
stats.value = await api.getStats();
} catch (error) {
console.error('Error cargando estadísticas:', error);
}
}
function handleWSMessage(event) {
const data = event.detail;
if (data.type === 'workers_updated' || data.type === 'favorites_updated') {
loadStats();
}
}
let interval = null;
onMounted(() => {
loadStats();
window.addEventListener('ws-message', handleWSMessage);
interval = setInterval(loadStats, 10000); // Actualizar cada 10 segundos
});
onUnmounted(() => {
if (interval) {
clearInterval(interval);
}
window.removeEventListener('ws-message', handleWSMessage);
});
</script>