4.8.9: Сортировка задач по completed и next_show_at
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m29s

This commit is contained in:
poignatov
2026-02-03 14:53:45 +03:00
parent ff9fec7d7a
commit c3d2c0d6a6
4 changed files with 51 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "play-life-web",
"version": "4.8.8",
"version": "4.8.9",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -493,6 +493,46 @@ function TaskList({ onNavigate, data, loading, backgroundLoading, error, onRetry
})
})
// Сортируем задачи внутри каждой группы проекта
Object.keys(groups).forEach(projectName => {
const group = groups[projectName]
// Сортируем невыполненные задачи: по completed DESC (больше завершений выше), затем по id ASC (раньше добавленные выше)
group.notCompleted.sort((a, b) => {
if (b.completed !== a.completed) {
return b.completed - a.completed // DESC
}
return a.id - b.id // ASC
})
// Сортируем выполненные задачи: бесконечные первыми, затем по next_show_at ASC (ранние в начале), NULL в начале
group.completed.sort((a, b) => {
// Проверяем, является ли задача бесконечной
const hasZeroPeriodA = a.repetition_period && isZeroPeriod(a.repetition_period)
const hasZeroDateA = a.repetition_date && isZeroDate(a.repetition_date)
const isInfiniteA = (hasZeroPeriodA && hasZeroDateA) || (hasZeroPeriodA && !a.repetition_date)
const hasZeroPeriodB = b.repetition_period && isZeroPeriod(b.repetition_period)
const hasZeroDateB = b.repetition_date && isZeroDate(b.repetition_date)
const isInfiniteB = (hasZeroPeriodB && hasZeroDateB) || (hasZeroPeriodB && !b.repetition_date)
// Бесконечные задачи идут первыми
if (isInfiniteA && !isInfiniteB) return -1
if (!isInfiniteA && isInfiniteB) return 1
if (isInfiniteA && isInfiniteB) return 0
// Для остальных: NULL значения идут первыми
if (!a.next_show_at && !b.next_show_at) return 0
if (!a.next_show_at) return -1
if (!b.next_show_at) return 1
// Сравниваем даты
const dateA = new Date(a.next_show_at).getTime()
const dateB = new Date(b.next_show_at).getTime()
return dateA - dateB // ASC
})
})
return groups
}, [tasks])