Автоматический коммит и пуш
This commit is contained in:
@@ -7730,6 +7730,7 @@ app.get('/api/system-info', requireAdmin, async (_, res) => {
|
||||
});
|
||||
|
||||
app.get('/api/dashboard', requireAuth, async (req, res) => {
|
||||
try {
|
||||
const payload = await cacheWrap('dashboard:' + scopeKey(req.user), STATS_TTL_MS, async () => {
|
||||
const DAYS = ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'];
|
||||
const tz = await appTimezone();
|
||||
@@ -7757,7 +7758,7 @@ app.get('/api/dashboard', requireAuth, async (req, res) => {
|
||||
`SELECT to_char(e.created_at AT TIME ZONE $TZ$, 'YYYY-MM-DD') AS d, count(*)::int AS n
|
||||
FROM entries e JOIN groups g ON g.id = e.group_id
|
||||
WHERE e.deleted_at IS NULL AND e.created_at >= (${tzWall()} - interval '13 days')::date${whereEntry}
|
||||
GROUP BY 1 ORDER BY 1`.replace(/\$TZ\$/g, '$' + (whereEntry ? whereGroupParams.length : 0) + 1),
|
||||
GROUP BY 1 ORDER BY 1`.replace(/\$TZ\$/g, '$' + ((whereEntry ? whereGroupParams.length : 0) + 1)),
|
||||
(whereEntry ? whereGroupParams : []).concat([tz])
|
||||
),
|
||||
pool.query(
|
||||
@@ -7765,7 +7766,7 @@ app.get('/api/dashboard', requireAuth, async (req, res) => {
|
||||
WHERE g.day_of_week IS NOT NULL AND g.time_start IS NOT NULL AND g.time_end IS NOT NULL
|
||||
AND g.day_of_week = EXTRACT(DOW FROM ${tzWall()})::int
|
||||
AND ${tzWall()}::time BETWEEN g.time_start AND g.time_end${whereGroup}
|
||||
ORDER BY g.id`.replace(/\$TZ\$/g, '$' + (whereGroup ? whereGroupParams.length : 0) + 1),
|
||||
ORDER BY g.id`.replace(/\$TZ\$/g, '$' + ((whereGroup ? whereGroupParams.length : 0) + 1)),
|
||||
(whereGroup ? whereGroupParams : []).concat([tz])
|
||||
),
|
||||
pool.query(
|
||||
@@ -7818,6 +7819,10 @@ app.get('/api/dashboard', requireAuth, async (req, res) => {
|
||||
};
|
||||
});
|
||||
res.json(payload);
|
||||
} catch (e) {
|
||||
console.error('GET /api/dashboard error:', e);
|
||||
res.status(500).json({ error: e.message || 'Ошибка загрузки дашборда' });
|
||||
}
|
||||
});
|
||||
|
||||
const entryFields = upload.fields([{ name: 'photo', maxCount: 10 }, { name: 'files', maxCount: 10 }]);
|
||||
|
||||
Reference in New Issue
Block a user