feat(post-lesson): подсказка при несчитанных коротких сообщениях (ошибка даты/автора)
This commit is contained in:
@@ -12018,6 +12018,11 @@ async function buildPostLessonTasks(user, days) {
|
||||
}
|
||||
}
|
||||
}
|
||||
const { rows: allShortRows } = await pool.query(
|
||||
`SELECT sm.id, sm.lesson_date::text AS d, sm.resident, sm.author_id, sm.created_at, u.name AS author_name, u.username AS author_username
|
||||
FROM short_messages sm LEFT JOIN users u ON u.id = sm.author_id
|
||||
WHERE sm.deleted_at IS NULL`
|
||||
);
|
||||
const tutorIds = [...new Set(groups.map(g => g.tutor_id).filter(Boolean))];
|
||||
const tutorMap = new Map();
|
||||
if (tutorIds.length) {
|
||||
@@ -12032,9 +12037,29 @@ async function buildPostLessonTasks(user, days) {
|
||||
const reportBasis = reportMap.get(key) || [];
|
||||
const shortsBasis = shortsMap.get(key) || [];
|
||||
const feedbackBasis = feedbackMap.get(key) || [];
|
||||
const countedShortIds = new Set(shortsBasis.map(x => x.id));
|
||||
const shortsRelated = allShortRows
|
||||
.filter(sm => {
|
||||
const gids = groupsByStudentName.get(String(sm.resident || '').trim().toLowerCase());
|
||||
if (!gids || !gids.has(g.id)) return false;
|
||||
if (countedShortIds.has(sm.id)) return false;
|
||||
const diffDays = Math.abs(new Date(sm.d + 'T00:00:00Z').getTime() - new Date(date + 'T00:00:00Z').getTime()) / (1000 * 60 * 60 * 24);
|
||||
if (diffDays > 1) return false;
|
||||
// отработка в другой группе: если дата совпадает с расписанием другой группы — не подсвечивать
|
||||
const smDow = new Date(sm.d + 'T00:00:00Z').getUTCDay();
|
||||
if (groups.some(og => og.id !== g.id && og.day_of_week === smDow)) return false;
|
||||
return true;
|
||||
})
|
||||
.map(sm => ({
|
||||
id: sm.id,
|
||||
resident: sm.resident || '',
|
||||
lesson_date: sm.d,
|
||||
author: sm.author_name || sm.author_username || '',
|
||||
reason: sm.d !== date ? 'date' : 'author',
|
||||
}));
|
||||
const steps = [
|
||||
{ key: 'report', label: 'Отчёт о занятии', done: reportDone, link: '/lessons.html', basis: reportBasis },
|
||||
{ key: 'shorts', label: 'Короткие сообщения', done: shortsDone, link: '/shorts.html', basis: shortsBasis },
|
||||
{ key: 'shorts', label: 'Короткие сообщения', done: shortsDone, link: '/shorts.html', basis: shortsBasis, related: shortsRelated },
|
||||
{ key: 'feedback', label: 'Обратная связь', done: feedbackDone, link: '/feedback.html', basis: feedbackBasis },
|
||||
];
|
||||
const completed = steps.filter(x => x.done).length;
|
||||
@@ -12051,6 +12076,7 @@ async function buildPostLessonTasks(user, days) {
|
||||
total: 3,
|
||||
overdue: date < today,
|
||||
all_done: completed === 3,
|
||||
shorts_related: shortsRelated,
|
||||
};
|
||||
});
|
||||
tasks.sort((a, b) => {
|
||||
|
||||
Reference in New Issue
Block a user