fix(feedback): past review in modal comes only from sent feedbacks

This commit is contained in:
dev
2026-10-08 11:30:32 +03:00
parent abecc94efd
commit a65d985f2b
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -2985,7 +2985,7 @@ app.get('/api/feedbacks/last', requireAuth, async (req, res) => {
const bs = branchScope(req.user);
if (bs.ids && !bs.ids.length) return null;
const params = [`%${resident}%`];
let cond = 'f.deleted_at IS NULL AND f.resident ILIKE $1';
let cond = 'f.deleted_at IS NULL AND f.sent_at IS NOT NULL AND f.resident ILIKE $1';
if (bs.ids) { params.push(bs.ids); cond += ` AND f.branch_id = ANY($${params.length}::int[])`; }
const { rows } = await pool.query(
`SELECT f.id, f.feedback_date, f.group_id, f.resident, f.topic, f.past_review, f.text, f.ai_status, f.sent_at, f.branch_id, f.deleted_at, g.name AS group_name