feat(postlesson): show group cover photo card in post-lesson tasks; tweaks

This commit is contained in:
dev
2026-11-05 15:09:46 +03:00
parent 62d96e5066
commit 123069281e
5 changed files with 858 additions and 8 deletions
+13 -1
View File
@@ -12251,7 +12251,7 @@ async function buildPostLessonTasks(user, days) {
groupParams.push(user.id);
}
const { rows: groups } = await pool.query(
`SELECT g.id, g.name, g.branch_id, g.tutor_id, g.day_of_week, g.time_start, g.time_end
`SELECT g.id, g.name, g.branch_id, g.tutor_id, g.cover_path, g.day_of_week, g.time_start, g.time_end
FROM groups g
WHERE g.deleted_at IS NULL AND g.hidden = false AND g.day_of_week IS NOT NULL AND g.time_start IS NOT NULL AND g.time_end IS NOT NULL${whereGroup}`,
groupParams
@@ -12360,6 +12360,17 @@ async function buildPostLessonTasks(user, days) {
const { rows: users } = await pool.query('SELECT id, name, username FROM users WHERE id = ANY($1::int[])', [tutorIds]);
for (const u of users) tutorMap.set(u.id, u.name || u.username || '');
}
const { rows: coverRows } = await pool.query(
`SELECT DISTINCT ON (group_id) group_id, photo_path FROM (
SELECT group_id, photo_path, created_at FROM group_photos WHERE group_id = ANY($1::int[])
UNION ALL
SELECT e.group_id, e.photo_path, e.created_at FROM entries e
WHERE e.group_id = ANY($1::int[]) AND e.deleted_at IS NULL AND e.photo_path IS NOT NULL AND e.photo_path <> ''
) p
ORDER BY group_id, created_at DESC NULLS LAST`,
[groupIds]
);
const coverByGroup = new Map(coverRows.map(r => [r.group_id, r.photo_path]));
const tasks = candidates.map(({ g, date }) => {
const key = g.id + '|' + date;
const reportDone = reportSet.has(key);
@@ -12398,6 +12409,7 @@ async function buildPostLessonTasks(user, days) {
key,
group_id: g.id,
group_name: g.name,
group_cover: g.cover_path || coverByGroup.get(g.id) || null,
tutor_id: g.tutor_id || null,
tutor_name: g.tutor_id ? (tutorMap.get(g.tutor_id) || '') : '',
lesson_date: date,