Прощальные сообщения: отправленные только при статусе «Отправлено»

This commit is contained in:
dev
2026-11-28 15:15:09 +03:00
parent 84ed0adc74
commit bd02cf6493
4 changed files with 9 additions and 4 deletions
+3 -1
View File
@@ -125,7 +125,7 @@ async function createFarewell(pool, data) {
return ins.rows[0];
}
async function listFarewells(pool, { isAdmin, userId, limit, offset, resident, deleted }) {
async function listFarewells(pool, { isAdmin, userId, limit, offset, resident, deleted, sent }) {
const lim = Math.min(Math.max(parseInt(limit, 10) || 20, 1), 100);
const off = Math.max(parseInt(offset, 10) || 0, 0);
const params = [];
@@ -134,6 +134,8 @@ async function listFarewells(pool, { isAdmin, userId, limit, offset, resident, d
const res = String(resident || '').trim();
if (res) { params.push('%' + res + '%'); cond.push(`f.resident ILIKE $${params.length}`); }
cond.push(deleted ? 'f.deleted_at IS NOT NULL' : 'f.deleted_at IS NULL');
if (sent === true) cond.push('f.sent_at IS NOT NULL');
else if (sent === false) cond.push('f.sent_at IS NULL');
const where = 'WHERE ' + cond.join(' AND ');
const total = await pool.query(`SELECT count(*)::int AS n FROM farewell_messages f ${where}`, params);
params.push(lim, off);