Bind archived filter as bool in ListTasks #65
@@ -158,11 +158,13 @@ func (s *Store) ListConversations(owner, projectID string) ([]core.Conversation,
|
||||
// ListTasks 跨项目任务列表(方案 A 侧栏数据源):默认仅未归档;includeArchived 含归档。
|
||||
func (s *Store) ListTasks(owner string, includeArchived bool) ([]core.Conversation, error) {
|
||||
q := `SELECT id,project_id,title,profile_id,pinned,archived,allow_cross_read,cross_private,permission_mode,session_note,created_at,updated_at FROM conversations WHERE owner=?`
|
||||
args := []any{owner}
|
||||
if !includeArchived {
|
||||
q += ` AND archived=0`
|
||||
q += ` AND archived=?`
|
||||
args = append(args, false)
|
||||
}
|
||||
q += ` ORDER BY pinned DESC, updated_at DESC`
|
||||
rows, err := s.db.Query(s.q(q), owner)
|
||||
rows, err := s.db.Query(s.q(q), args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func openTestStore(t *testing.T) *Store {
|
||||
admin.Exec("DROP SCHEMA IF EXISTS " + schema + " CASCADE")
|
||||
admin.Close()
|
||||
})
|
||||
st, err := OpenPostgres(dsn+"&search_path="+schema, filepath.Join(t.TempDir(), "artifacts"))
|
||||
st, err := OpenPostgres(withTestSearchPath(dsn, schema), filepath.Join(t.TempDir(), "artifacts"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -47,6 +47,21 @@ func openTestStore(t *testing.T) *Store {
|
||||
return st
|
||||
}
|
||||
|
||||
// withTestSearchPath 把用例 schema 放到 search_path 最前,并保留 public,
|
||||
// 以便看到已安装在 public 的 pg_trgm。svc.sh 给出的是无查询串的 URL;
|
||||
// 键值对 DSN(不含 ://)用空格追加。
|
||||
func withTestSearchPath(dsn, schema string) string {
|
||||
path := schema + ",public"
|
||||
if !strings.Contains(dsn, "://") {
|
||||
return dsn + " search_path=" + path
|
||||
}
|
||||
sep := "?"
|
||||
if strings.Contains(dsn, "?") {
|
||||
sep = "&"
|
||||
}
|
||||
return dsn + sep + "search_path=" + path
|
||||
}
|
||||
|
||||
func isSQLite(st *Store) bool { return st.Dialect() == "sqlite" }
|
||||
|
||||
// 迁移验收:全量应用 → 状态 1..4 → 回滚到 1(老库形态)→ 再次前进(既有部署升级路径)。
|
||||
|
||||
Reference in New Issue
Block a user