4.8.9: Сортировка задач по completed и next_show_at
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m29s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m29s
This commit is contained in:
@@ -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])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user