Прощальные сообщения: отправленные только при статусе «Отправлено»
This commit is contained in:
+3
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user