Fix trash: add missing deleted_at IS NOT NULL filter to main query
This commit is contained in:
@@ -2252,7 +2252,7 @@ app.get('/api/trash', requireAuth, async (req, res) => {
|
||||
const { limit, offset } = req.query;
|
||||
const bw = branchScope(req.user);
|
||||
const scoped = req.user.role !== 'admin';
|
||||
let where = ' WHERE 1=1';
|
||||
let where = ' WHERE e.deleted_at IS NOT NULL';
|
||||
const params = [];
|
||||
if (scoped) {
|
||||
if (bw.ids.length) {
|
||||
@@ -2263,9 +2263,8 @@ app.get('/api/trash', requireAuth, async (req, res) => {
|
||||
}
|
||||
console.log(`[TRASH] User ${req.user.id} (${req.user.username}) role=${req.user.role} branch_ids=${JSON.stringify(bw.ids)} scoped=${scoped} where=${where} params=${JSON.stringify(params)}`);
|
||||
const { rows: crows } = await pool.query(
|
||||
`SELECT count(*)::int AS n FROM entries e JOIN groups g ON g.id = e.group_id WHERE e.deleted_at IS NOT NULL` +
|
||||
(scoped ? (bw.ids.length ? ` AND g.branch_id IN (${bw.ids.map((_, i) => `$${i + 1}`).join(',')})` : ' AND 1 = 0') : ''),
|
||||
scoped ? bw.ids : []
|
||||
`SELECT count(*)::int AS n FROM entries e JOIN groups g ON g.id = e.group_id ${where}`,
|
||||
params
|
||||
);
|
||||
const total = crows[0].n;
|
||||
let q = `SELECT e.*, g.name AS group_name FROM entries e
|
||||
|
||||
Reference in New Issue
Block a user