Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JuseAR27/Unisierra-eats/llms.txt

Use this file to discover all available pages before exploring further.

The reports page gives administrators a snapshot of platform-wide engagement and product performance. Located at admin/reportes.html, it is powered by the iniciarReportes() function in admin.js, which runs automatically when the admin router detects reportes.html in the current URL.

Data Source

All analytics on this page derive from a single API call to GET /api/productos. This endpoint already returns each product’s computed calificacion (average rating) and numResenas (total review count) by joining the Productos and Resenas tables server-side. No additional endpoints are needed. Once the response is received, the function filters the full product list to only those with at least one review:
const evaluados = productos.filter(p => p.numResenas > 0);
All metrics and rankings are calculated exclusively from the evaluados array.
Products with zero reviews are excluded from all analytics widgets and ranking lists. They do not affect the platform average, review count, or any product rankings.

Analytics Widgets

Total Reviews

The sum of numResenas across all evaluated products. Displayed in the #rep-total DOM element. Represents the total number of reviews ever submitted and not deleted across the entire platform.

Platform Average

A weighted average rating calculated as Σ(calificacion × numResenas) / totalResenas, displayed as X.X / 5.0 in #rep-promedio. Products with more reviews carry proportionally more weight in this score.

Most Popular Product

The single product with the highest numResenas value among evaluated products. Its name appears in #rep-pop-nombre and its total review count in #rep-pop-votos as N evaluaciones.

Rankings

Two sorted lists — top 3 best-rated (sorted by calificacion DESC) and top 3 lowest-rated (sorted by calificacion ASC). Each entry shows the product image, name, review count, and star score.

Weighted Average Calculation

The platform average is computed using a weighted mean so that a product rated 5.0 by one user does not unfairly outrank a product rated 4.8 by hundreds of users. The evaluados.forEach loop accumulates the totals and simultaneously tracks the most popular product:
let totalResenas = 0;
let sumaCalificaciones = 0;
let masPopular = evaluados[0];

evaluados.forEach(p => {
    totalResenas += p.numResenas;
    sumaCalificaciones += (p.calificacion * p.numResenas);

    if (p.numResenas > masPopular.numResenas) {
        masPopular = p;
    }
});

const promedioGeneral = (sumaCalificaciones / totalResenas).toFixed(1);
masPopular is initialized to evaluados[0] (the first reviewed product) and updated whenever a product with a higher numResenas is encountered. The result is the single product with the most reviews.

Product Rankings

Rankings are derived from the evaluados array using Array.sort() on a spread copy to avoid mutating the original:
// Top 3 best-rated
const topMejores = [...evaluados].sort((a, b) => b.calificacion - a.calificacion).slice(0, 3);

// Top 3 lowest-rated
const topPeores = [...evaluados].sort((a, b) => a.calificacion - b.calificacion).slice(0, 3);
Each ranking entry is rendered as a list item inside #rep-lista-mejores or #rep-lista-peores and displays:
FieldSource
Product imagep.imagen (45×45px, rounded)
Product namep.nombre
Review countp.numResenas (shown as N reseñas registradas)
Star scorep.calificacion.toFixed(1)
Best-rated scores are highlighted in orange (var(--primary-orange)). Lowest-rated scores are highlighted in red (#d93025).

Build docs developers (and LLMs) love