fix: exclude deleted students/entries/groups from journal student filter

This commit is contained in:
dev
2026-11-03 09:29:08 +03:00
parent b360ca8303
commit c2ef292237
+7 -1
View File
@@ -9285,7 +9285,13 @@ app.get('/api/students/names', requireAuth, async (req, res) => {
const { rows } = await pool.query(
`SELECT DISTINCT e.student_name AS name FROM entries e
JOIN groups g ON g.id = e.group_id
WHERE e.student_name IS NOT NULL AND e.student_name <> ''${bw.where}
WHERE e.student_name IS NOT NULL AND e.student_name <> ''
AND e.deleted_at IS NULL
AND g.deleted_at IS NULL
AND NOT EXISTS (
SELECT 1 FROM students s
WHERE TRIM(s.name) = TRIM(e.student_name) AND s.deleted_at IS NOT NULL
)${bw.where}
ORDER BY name`,
bw.params
);