Skip to content

Commit 19b90cc

Browse files
authored
Fix in-progress tasks not appearing in Today and All Tasks views (#894)
* Fix in-progress tasks not appearing in Today and All Tasks views * fixup! Fix in-progress tasks not appearing in Today and All Tasks views
1 parent c383246 commit 19b90cc

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

backend/modules/tasks/queries/metrics-queries.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async function fetchTodayPlanTasks(visibleTasksWhere) {
9494
'cancelled',
9595
];
9696

97-
return await Task.findAll({
97+
const tasks = await Task.findAll({
9898
where: {
9999
[Op.and]: [
100100
visibleTasksWhere,
@@ -112,7 +112,7 @@ async function fetchTodayPlanTasks(visibleTasksWhere) {
112112
{ defer_until: { [Op.lte]: now } },
113113
],
114114
},
115-
// Exclude recurring parent tasks - only include non-recurring tasks or recurring instances
115+
// Include non-recurring tasks, recurring parents, and recurring instances
116116
{
117117
[Op.or]: [
118118
{
@@ -122,11 +122,21 @@ async function fetchTodayPlanTasks(visibleTasksWhere) {
122122
[Op.or]: [
123123
{ recurrence_type: 'none' },
124124
{ recurrence_type: null },
125+
{ recurrence_type: '' },
125126
],
126127
},
127128
{ recurring_parent_id: null },
128129
],
129130
},
131+
{
132+
// Recurring parent tasks
133+
[Op.and]: [
134+
{ recurrence_type: { [Op.ne]: 'none' } },
135+
{ recurrence_type: { [Op.ne]: null } },
136+
{ recurrence_type: { [Op.ne]: '' } },
137+
{ recurring_parent_id: null },
138+
],
139+
},
130140
{
131141
// Recurring instances (not parents)
132142
recurring_parent_id: { [Op.ne]: null },
@@ -142,6 +152,18 @@ async function fetchTodayPlanTasks(visibleTasksWhere) {
142152
['project_id', 'ASC'],
143153
],
144154
});
155+
156+
// Deduplicate: exclude recurring parents that already have instances in the list
157+
const parentIdsWithInstances = new Set(
158+
tasks
159+
.filter((t) => t.recurring_parent_id)
160+
.map((t) => t.recurring_parent_id)
161+
);
162+
163+
return tasks.filter(
164+
(t) =>
165+
!parentIdsWithInstances.has(t.id) || t.recurring_parent_id !== null
166+
);
145167
}
146168

147169
async function fetchTasksDueToday(visibleTasksWhere, userTimezone) {

backend/modules/tasks/queries/query-builders.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ async function filterTasksByParams(
3333
[Op.or]: [
3434
{ recurrence_type: 'none' },
3535
{ recurrence_type: null },
36+
{ recurrence_type: '' },
3637
],
3738
},
3839
{ recurring_parent_id: null },
@@ -42,6 +43,7 @@ async function filterTasksByParams(
4243
[Op.and]: [
4344
{ recurrence_type: { [Op.ne]: 'none' } },
4445
{ recurrence_type: { [Op.ne]: null } },
46+
{ recurrence_type: { [Op.ne]: '' } },
4547
{ recurring_parent_id: null },
4648
{
4749
[Op.or]: [
@@ -133,6 +135,7 @@ async function filterTasksByParams(
133135
[Op.or]: [
134136
{ recurrence_type: 'none' },
135137
{ recurrence_type: null },
138+
{ recurrence_type: '' },
136139
],
137140
},
138141
{ recurring_parent_id: null },
@@ -145,6 +148,7 @@ async function filterTasksByParams(
145148
[Op.and]: [
146149
{ recurrence_type: { [Op.ne]: 'none' } },
147150
{ recurrence_type: { [Op.ne]: null } },
151+
{ recurrence_type: { [Op.ne]: '' } },
148152
{ recurring_parent_id: null },
149153
{ status: { [Op.in]: todayPlanStatuses } },
150154
notDeferredCondition,

0 commit comments

Comments
 (0)