Skip to content

Commit

Permalink
Group by overdue
Browse files Browse the repository at this point in the history
  • Loading branch information
wildjames committed Nov 24, 2024
1 parent e92edc0 commit 5683981
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions todoqueue_frontend/src/components/tasks/Tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,21 @@ const Tasks = ({ households, selectedHousehold, setSelectedHousehold, showSelect
<div className="task-container ">
{tasks
.filter(task => task.staleness !== 0)
.sort((a, b) => {
if (a.staleness === b.staleness) {
// If staleness is the same, sort by averageTimeToComplete
return a.averageTimeToComplete - b.averageTimeToComplete;
} else if (a.staleness === 1) {
// a is stale (staleness === 1), so it comes before b
return -1;
} else if (b.staleness === 1) {
// b is stale, so a comes after b
return 1;
} else {
// Both have staleness between 0 and 1, sort by averageTimeToComplete
return a.averageTimeToComplete - b.averageTimeToComplete;
}
})
.map((task) => (
<div className="task-wrapper" key={task.id}>
<div
Expand Down

0 comments on commit 5683981

Please sign in to comment.