fix(notify): daily summary includes lists shared through a group

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sandrodachandClaude Opus 5.5 committed 2026-10-30 09:54:10 +01:00
1 parent a69bcbaf10
commit 6b3c32a370
2 files changed
+38 -3

No files matched your search

+8 -3
View File
@@ -208,15 +208,20 @@ func (s *Store) ActiveUserIDs() []string {
return out
}
// OpenTasksDueBefore lists the user's open tasks (own ones and those of shared task lists) due before
// OpenTasksDueBefore lists the user's open tasks (own ones, those of own lists and of lists shared with
// the user directly or through a group) due before
// the given day (YYYY-MM-DD, exclusive), oldest first.
func (s *Store) OpenTasksDueBefore(userID, beforeDay string) ([]SummaryTask, error) {
rows, err := s.db.Query(`SELECT t.content, t.due_date, COALESCE(l.title, '')
FROM thoughts t LEFT JOIN task_lists l ON l.id = t.task_list_id
WHERE (t.status = 'kept' OR (t.status = 'converted' AND t.converted_type = 'task'))
AND t.is_completed = 0 AND t.due_date != '' AND substr(t.due_date, 1, 10) < ?
AND (t.user_id = ? OR (t.task_list_id != '' AND t.task_list_id IN (SELECT task_list_id FROM task_list_shares WHERE target_type = 'user' AND target_id = ?)))
ORDER BY t.due_date`, beforeDay, userID, userID)
AND (t.user_id = ? OR (t.task_list_id != '' AND t.task_list_id IN (
SELECT id FROM task_lists WHERE user_id = ?
UNION SELECT task_list_id FROM task_list_shares WHERE target_type = 'user' AND target_id = ?
UNION SELECT task_list_id FROM task_list_shares WHERE target_type = 'team'
AND target_id IN (SELECT team_id FROM team_members WHERE user_id = ?))))
ORDER BY t.due_date`, beforeDay, userID, userID, userID, userID)
if err != nil {
return nil, err
}