feat(navigation): count open workspace todos and style tab badges as notification dots
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 56s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 56s
This commit is contained in:
1 parent
1168c7e2ea
commit
290848a93e
5 files changed
+67
-42
No files matched your search
@@ -1910,6 +1910,31 @@ func (s *Store) GetDashboardStats(userID string) (*domain.DashboardStats, error)
|
||||
_ = s.db.QueryRow(`SELECT COUNT(*) FROM documents WHERE user_id = ? AND is_archived = 0`, userID).Scan(&st.DocsCount)
|
||||
_ = s.db.QueryRow(`SELECT COUNT(*) FROM thoughts WHERE user_id = ? AND status = 'discarded'`, userID).Scan(&st.DiscardedCount)
|
||||
_ = s.db.QueryRow(`SELECT COUNT(*) FROM lists l JOIN space_members sm ON sm.space_id = l.space_id WHERE sm.user_id = ?`, userID).Scan(&st.ListsCount)
|
||||
|
||||
// Count open (uncompleted) To-Dos across accessible workspace documents (owned or shared)
|
||||
docRows, err := s.db.Query(`
|
||||
SELECT blocks_json FROM documents
|
||||
WHERE (user_id = ? OR id IN (SELECT doc_id FROM doc_shares WHERE user_id = ?))
|
||||
AND is_archived = 0`,
|
||||
userID, userID,
|
||||
)
|
||||
if err == nil {
|
||||
for docRows.Next() {
|
||||
var bj string
|
||||
if err := docRows.Scan(&bj); err == nil && bj != "" {
|
||||
var blocks []domain.DocumentBlock
|
||||
if err := json.Unmarshal([]byte(bj), &blocks); err == nil {
|
||||
for _, b := range blocks {
|
||||
if b.Type == "todo" && !b.Checked {
|
||||
st.DocsTodosOpenCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ = docRows.Close()
|
||||
}
|
||||
|
||||
return st, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user