diff --git a/src/pages/Analytics/General.tsx b/src/pages/Analytics/General.tsx index be9b7b88..33f6d581 100644 --- a/src/pages/Analytics/General.tsx +++ b/src/pages/Analytics/General.tsx @@ -131,11 +131,21 @@ export const General: FC = ({ data, day }) => { const generalResponse = Object.entries(data).reduce( (total, [fatherKey, values]) => { const value = Object.keys(values).reduce((totalValue, key) => { - if (Number(key) - currentDate < 0) { + const keyTimestamp = Number(key); + const todayStart = moment().startOf('day').unix(); + const todayEnd = moment().endOf('day').unix(); + + // Включаем данные за сегодня и прошлые дни, исключаем будущие дни + if (keyTimestamp >= todayStart && keyTimestamp <= todayEnd) { + // Сегодняшний день - включаем return { ...totalValue, [key]: values[key] }; + } else if (keyTimestamp < todayStart) { + // Прошлые дни - включаем + return { ...totalValue, [key]: values[key] }; + } else { + // Будущие дни - исключаем + return totalValue; } - - return totalValue; }, {}); return { ...total, [fatherKey]: value };