Changeset 0.28.0.8 (#180)

This commit is contained in:
2026-03-12 22:49:35 +00:00
parent f3f5afd14c
commit aa870f1040
14 changed files with 679 additions and 116 deletions

View File

@@ -41,6 +41,16 @@ func (s *MemoryStore) Upsert(ctx context.Context, m *models.Memory) error {
return err
}
func (s *MemoryStore) Update(ctx context.Context, m *models.Memory) error {
_, err := DB.ExecContext(ctx, `
UPDATE memories
SET key = ?, value = ?, confidence = ?, status = ?,
source_channel_id = ?, updated_at = datetime('now')
WHERE id = ?
`, m.Key, m.Value, m.Confidence, m.Status, m.SourceChannelID, m.ID)
return err
}
func (s *MemoryStore) GetByID(ctx context.Context, id string) (*models.Memory, error) {
m := &models.Memory{}
err := DB.QueryRowContext(ctx, `
@@ -202,6 +212,25 @@ func (s *MemoryStore) CountByOwner(ctx context.Context, scope, ownerID string) (
return count, err
}
func (s *MemoryStore) ListByStatus(ctx context.Context, status string, limit int) ([]models.Memory, error) {
if limit <= 0 || limit > 500 {
limit = 100
}
rows, err := DB.QueryContext(ctx, `
SELECT id, scope, owner_id, user_id, key, value,
source_channel_id, confidence, status, created_at, updated_at
FROM memories
WHERE status = ?
ORDER BY created_at DESC
LIMIT ?
`, status, limit)
if err != nil {
return nil, err
}
defer rows.Close()
return s.scanMemories(rows)
}
// ── Helpers ─────────────────────────────────
func (s *MemoryStore) scanMemories(rows *sql.Rows) ([]models.Memory, error) {
@@ -222,3 +251,6 @@ func (s *MemoryStore) scanMemories(rows *sql.Rows) ([]models.Memory, error) {
}
return memories, rows.Err()
}
// ensure compile-time interface satisfaction
var _ store.MemoryStore = (*MemoryStore)(nil)