fix: dashboad ticket count conting only logged in user's tickets

This commit is contained in:
canove
2021-01-15 07:03:47 -03:00
parent d3a9b2a2f6
commit 454fd6ce08
2 changed files with 4 additions and 11 deletions

View File

@@ -109,7 +109,6 @@ const ListTicketsService = async ({
if (date) { if (date) {
whereCondition = { whereCondition = {
...whereCondition,
createdAt: { createdAt: {
[Op.between]: [+startOfDay(parseISO(date)), +endOfDay(parseISO(date))] [Op.between]: [+startOfDay(parseISO(date)), +endOfDay(parseISO(date))]
} }
@@ -127,7 +126,7 @@ const ListTicketsService = async ({
}; };
} }
const limit = 20; const limit = 40;
const offset = limit * (+pageNumber - 1); const offset = limit * (+pageNumber - 1);
const { count, rows: tickets } = await Ticket.findAndCountAll({ const { count, rows: tickets } = await Ticket.findAndCountAll({

View File

@@ -41,17 +41,11 @@ const Chart = () => {
setChartData(prevState => { setChartData(prevState => {
let aux = [...prevState]; let aux = [...prevState];
aux.map(a => { aux.forEach(a => {
tickets.forEach(ticket => { tickets.forEach(ticket => {
if ( format(startOfHour(parseISO(ticket.createdAt)), "HH:mm") === a.time &&
format(startOfHour(parseISO(ticket.createdAt)), "HH:mm") === a.time a.amount++;
) {
return a.amount++;
} else {
return a;
}
}); });
return a;
}); });
return aux; return aux;