Improve photo search: include path, student name, and group name in search query
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@
|
|||||||
<div class="main">
|
<div class="main">
|
||||||
<h2>Фото</h2>
|
<h2>Фото</h2>
|
||||||
<div class="filters">
|
<div class="filters">
|
||||||
<div><label>Поиск</label><input type="text" id="searchInput" class="search-input" placeholder="Описание или имя"></div>
|
<div><label>Поиск</label><input type="text" id="searchInput" class="search-input" placeholder="Описание, файл или имя"></div>
|
||||||
<div><label>Ученик</label><input type="text" id="studentFilter" list="studentFilterList" placeholder="Все / введите имя..."><datalist id="studentFilterList"></datalist></div>
|
<div><label>Ученик</label><input type="text" id="studentFilter" list="studentFilterList" placeholder="Все / введите имя..."><datalist id="studentFilterList"></datalist></div>
|
||||||
<div><label>По лицам</label><select id="faceStudentFilter"><option value="">Без фильтра</option><option value="__unassigned__">Неопознанные лица</option></select></div>
|
<div><label>По лицам</label><select id="faceStudentFilter"><option value="">Без фильтра</option><option value="__unassigned__">Неопознанные лица</option></select></div>
|
||||||
<div><label>Группа</label><select id="groupFilter"><option value="">Все группы</option></select></div>
|
<div><label>Группа</label><select id="groupFilter"><option value="">Все группы</option></select></div>
|
||||||
|
|||||||
@@ -11446,7 +11446,7 @@ app.get('/api/photos', requireAuth, async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
const conditions = [];
|
const conditions = [];
|
||||||
const params = [];
|
const params = [];
|
||||||
if (search) { params.push(`%${search}%`); conditions.push(`t.title ILIKE $${params.length}`); }
|
if (search) { params.push(`%${search}%`); conditions.push(`(t.title ILIKE $${params.length} OR t.path ILIKE $${params.length} OR COALESCE(t.student_name, '') ILIKE $${params.length} OR COALESCE(t.group_name, '') ILIKE $${params.length})`); }
|
||||||
if (student_name) { params.push(student_name); conditions.push(`t.student_name = $${params.length}`); }
|
if (student_name) { params.push(student_name); conditions.push(`t.student_name = $${params.length}`); }
|
||||||
if (group_id) { params.push(group_id); conditions.push(`t.group_id = $${params.length}`); }
|
if (group_id) { params.push(group_id); conditions.push(`t.group_id = $${params.length}`); }
|
||||||
if (student_id) {
|
if (student_id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user