Add pagination to audit page
This commit is contained in:
@@ -607,11 +607,12 @@ app.put('/api/settings', requireAdmin, async (req, res) => {
|
||||
|
||||
app.get('/api/audit', requireAdmin, async (req, res) => {
|
||||
const limit = Math.min(parseInt(req.query.limit, 10) || 100, 1000);
|
||||
const offset = Math.max(parseInt(req.query.offset, 10) || 0, 0);
|
||||
const { rows } = await pool.query(
|
||||
`SELECT a.id, a.action, a.target, a.ip, a.created_at, a.user_id, u.username AS user_name
|
||||
FROM audit_log a LEFT JOIN users u ON u.id = a.user_id
|
||||
ORDER BY a.id DESC LIMIT $1`,
|
||||
[limit]
|
||||
ORDER BY a.id DESC LIMIT $1 OFFSET $2`,
|
||||
[limit, offset]
|
||||
);
|
||||
res.json(rows);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user