Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 0 additions & 111 deletions controllers/productos.js

This file was deleted.

40 changes: 8 additions & 32 deletions controllers/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const get_statistics_products = async (req, res = response) => {
return res.status(401).json({ mensaje: `Token inválido o expirado: ${error.message}` });
}

const { idSeller, year, month } = req.params;
console.log(`Parámetros recibidos - idSeller: ${idSeller}, year: ${year}, month: ${month}`);
const { year, month } = req.params;
console.log(`Parámetros recibidos - idSeller: ${uid}, year: ${year}, month: ${month}`);

if (!idSeller || !year || !month) {
if (!uid || !year || !month) {
console.log("Faltan parámetros requeridos.");
return res.status(400).json({ mensaje: "Faltan parámetros requeridos: idSeller, year, month" });
}
Expand All @@ -41,37 +41,21 @@ const get_statistics_products = async (req, res = response) => {
`SELECT
p.nombre AS producto,
COUNT(ped.idPedido) AS cantidad_vendida
<<<<<<< HEAD
FROM productos p
LEFT JOIN pedidos ped
ON p.idProducto = ped.idProducto
LEFT JOIN estadoPedido ep
ON ped.idEstadoPedido = ep.idEstadoPedido
WHERE
p.idVendedor = ?
AND ep.estadoPedido = 'entregado'
AND MONTH(ped.fechaPedido) = ?
AND YEAR(ped.fechaPedido) = ?
GROUP BY p.idProducto
ORDER BY cantidad_vendida DESC
LIMIT 10;`,
[idSeller, month, year]
);
=======
FROM productos p
LEFT JOIN pedidos ped
ON p.idProducto = ped.idProducto
LEFT JOIN estadopedido ep
ON ped.idEstadoPedido = ep.idEstadoPedido
WHERE
p.idUsuario = ?
AND ped.estado = 'entregado'
p.idVendedor = ?
AND ep.estadoPedido = 'entregado'
AND MONTH(ped.fechaPedido) = ?
AND YEAR(ped.fechaPedido) = ?
GROUP BY p.idProducto
ORDER BY cantidad_vendida DESC
LIMIT 10;`,
[idSeller, month, year]
[uid, month, year]
);
>>>>>>> ae337fffd9fa6b332b3651f8e66834f81a7616e2

console.log(`Consulta ejecutada. Productos encontrados: ${productos.length}`);

Expand All @@ -80,16 +64,8 @@ const get_statistics_products = async (req, res = response) => {
return res.status(404).json({ mensaje: "No se encontraron productos vendidos para este vendedor en el mes y año especificados." });
}

<<<<<<< HEAD
console.log('Productos encontrados:', productos); // Imprime los productos encontrados antes de enviar la respuesta

console.log('Productos encontrados, enviando respuesta');
return res.status(200).json({ productos });

=======
console.log("Productos encontrados, enviando respuesta.");
res.status(200).json({ productos });
>>>>>>> ae337fffd9fa6b332b3651f8e66834f81a7616e2
} catch (error) {
console.error("Error al obtener las estadísticas de productos:", error);
res.status(500).json({ mensaje: "Error interno del servidor al obtener las estadísticas de productos." });
Expand Down
131 changes: 0 additions & 131 deletions controllers/usuarios.js

This file was deleted.

22 changes: 0 additions & 22 deletions routes/productos.js

This file was deleted.

2 changes: 1 addition & 1 deletion routes/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {validarJWT} = require('../helpers/validar-jwt');

const router = Router();

router.get('/statistics/:idSeller/:year/:month', validarJWT, get_statistics_products);
router.get('/statistics/:year/:month', validarJWT, get_statistics_products);
router.get('/offered/:idSeller', validarJWT, get_products_offered);
router.post("/", upload.single('foto'), validarJWT, add_product);
router.get("/orderproducts/:idPedido", validarJWT, get_order_product);
Expand Down
Empty file removed routes/users-doc.js
Empty file.
17 changes: 0 additions & 17 deletions routes/usuarios.js

This file was deleted.

1 change: 0 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ app.use(cors(corsOptions));
app.use(express.json({ limit: '50mb' }));
app.use(cookieParser());

app.use('/usuarios', require('./routes/usuarios'));
app.use('/auth', require('./routes/auth'));
app.use('/products', require('./routes/products'));
app.use('/utils', require('./routes/utils'));
Expand Down
Loading
Loading